Reputation: 2881
I have a couple projects and I'm wondering the best way to share logback configurations between them. The setup looks something like this:
Physical Machine 1
Project 1
Project 2
Project 3
Physical Machine 2
Project 1
Project 4
To avoid duplication, I don't want to stick a logback.xml in each projects resources directory. Should I bundle the logback.xml as another project and make it a dependency for each of the projects? Or just place it somewhere on the hard drive and have each project read in the logback.xml on startup? Or something else?
Also for development, they are all in the same JVM, so sharing a logback-test.xml and not reading from disk would be nice.
Upvotes: 3
Views: 1928
Reputation: 813
I generally bundle configuration files as a standalone project so that it can be used across multiple projects.
I think the principal argument relies on versionning and how easy it's going to be if it's a dependency. On the file system you'd have to keep several versions of the file in subdirectories and it could quickly become messy.
If you're using Maven, here's a link which could help you.
Upvotes: 2
Reputation: 38320
Here is the Logback Configuratrion Chapter in the online manual.
When Logback is starting up, it attempts to load a logback configuration file from the classpath.
A solution to your question is to store the shared logback.xml file in a directory that is in the classpath of each of the projects.
Upvotes: 1