specify custom logging.properties under tomcat

不羁岁月 提交于 2019-12-12 14:10:54

问题


I'd like to have 2 webapp under a tomcat, the 2 project should have their own logging.properties. I know this is possible, if you put logging.properties in the war file, but I'd like to specify a custom loggin.properties file (out of my deployed war). Is that possible?


回答1:


You can specify what file will be used. The ${catalina.base}/conf/logging.properties file is referenced by Tomcat startup scripts,

catalina.sh :

LOGGING_CONFIG (Optional) Override Tomcat's logging config file
LOGGING_CONFIG="-Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties"

But you can not use two separate properties files for separate applications at this level. If you require separate (per app) settings, you need to use your local app WEB-INF/classes/logging.properties file (means yes, you should put it to your war file).

Another solution is to use log4j (http://tomcat.apache.org/tomcat-7.0-doc/logging.html#Using_Log4j) which is way more flexible. log4j.properties sits inside $CATALINA_BASE/lib, it has all settings inside one config (properties) file, but you can configure separate log4j.appender for every application and log each application to separate log file. You can have DEBUG log level for one app, and simple INFO for another app.



来源:https://stackoverflow.com/questions/16772188/specify-custom-logging-properties-under-tomcat

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