How to read logback configuration file from system environment in tomcat 7

↘锁芯ラ 提交于 2019-12-23 20:05:19

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!