简体   繁体   English

防止同时记录到catalina.out和log4j日志文件

[英]Prevent to log both to catalina.out and log4j logfiles

I know, that there are many similar questions and answers about logging to catalina.out and logging to log4j logfiles, but so far i haven't found a correct answer to my problem and i don't want to turn off logging to catalina.out 我知道,关于登录到catalina.out和登录到log4j日志文件也有很多类似的问题和答案,但是到目前为止,我还没有找到解决我的问题的正确答案,我也不想关闭登录到catalina的记录。出

My motivation is to have a split here between logmessages related to my application and logmessages related to tomcaterrors. 我的动机是在与我的应用程序有关的日志消息与与tomcaterrors有关的日志消息之间进行区分。

I want to make sure, when something is logged into log4j's own logfiles, that it is not doubly logged into catalina.out, but when it is not handled by log4j, that it is still written into catalina.out. 我想确保在将某些内容登录到log4j自己的日志文件中时,不会将其双重登录到catalina.out中,但是当未由log4j处理时,仍将其写入catalina.out中。

But how? 但是如何?

try this configuration 试试这个配置

# console out only for org.apache.catalina
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.logger.org.apache.catalina=debug, A1
log4j.additivity.org.apache.catalina=false


# common output
log4j.appender.A2=org.apache.log4j.FileAppender
log4j.appender.A2.file=console.log
log4j.appender.A2.layout=org.apache.log4j.PatternLayout

log4j.rootLogger=info, A2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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