简体   繁体   中英

How to share logback.xml between projects

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM