在tomcat下指定自定义logging.properties [英] specify custom logging.properties under tomcat

查看:890
本文介绍了在tomcat下指定自定义logging.properties的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在tomcat下有2个webapp,这2个项目应该有自己的logging.properties.我知道这是有可能的,如果您将warning文件中的logging.properties放在了其中,但是我想指定一个自定义的loggin.properties文件(不在我部署的war中).有可能吗?

解决方案

您可以指定要使用的文件. Tomcat启动脚本引用了 $ {catalina.base}/conf/logging.properties 文件.

catalina.sh:

LOGGING_CONFIG(可选)覆盖Tomcat的日志配置文件
LOGGING_CONFIG =-Djava.util.logging.config.file = $ CATALINA_BASE/conf/logging.properties"

但是您不能在此级别将两个单独的属性文件用于单独的应用程序.如果需要单独的(每个应用程序)设置,则需要使用本地应用程序 WEB-INF/classes/logging.properties 文件(意味着可以,应将其放入war文件中).

另一种解决方案是使用log4j( http://tomcat.apache .org/tomcat-7.0-doc/logging.html#Using_Log4j ),该方法更加灵活. log4j.properties位于$ CATALINA_BASE/lib中,它在一个配置(属性)文件中具有所有设置,但是您可以为每个应用程序配置单独的log4j.appender并将每个应用程序记录到单独的日志文件中.您可以为一个应用程序设置DEBUG日志级别,为另一个应用程序设置简单的INFO.

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?

解决方案

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.

这篇关于在tomcat下指定自定义logging.properties的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆