问题
Let me tell the story first:
We have 2 j2ee web applications AAA and BBB, and we want to put them in the same server.
Right now they both have the logback.xml in their class path, which is in /src/main/resources for the maven project.
We want to put all the configuration files in a directory, such as ${app_home}, and let the web applications to find their configuration files by themselves.
Like we put AAA_logback.xml and BBB_logback.xml into ${app_home}, and let the web application to find them automatically.
We use Tomcat 7 to deploy the web applications, if we want to achieve this, do we need any change on Tomcat 7 configuration?
There is a similar question: How to read Logback configuration file from path outside the war file?
I wish I ask my question clearly with my poor English.
回答1:
I would suggest you to keep the original logback.xml in the respective classpaths itself and include the actual stuff from ${app_home}/...
see www.logback.qos.ch/manual/configuration.html#fileInclusion
In this way you can specify different files for different apps.
来源:https://stackoverflow.com/questions/28349088/how-to-read-logback-configuration-file-from-system-environment-in-tomcat-7