Is it safe to use the same log file by two differe

2019-06-14 02:21发布

log4j.rootLogger=error,network
log4j.appender.defaultLog=org.apache.log4j.ConsoleAppender
log4j.appender.defaultLog.DatePattern=${roll.pattern.daily}
log4j.appender.defaultLog.file=/var/log/tomcat7/hello.log
log4j.appender.defaultLog.layout=org.apache.log4j.PatternLayout
log4j.appender.defaultLog.layout.ConversionPattern=${log.format}

log4j.logger.timing=info, timing
log4j.appender.timing=org.apache.log4j.ConsoleAppender
log4j.appender.timing.DatePattern=${roll.pattern.daily}
log4j.appender.timing.file=/var/log/tomcat7/hello.log
log4j.appender.timing.layout=org.apache.log4j.PatternLayout
log4j.appender.timing.layout.ConversionPattern=${log.format}

What I want to achieve is log network in level ERROR and timing in level INFO. Can I do what I have described up there?. Or will it cause any problem two processors trying to access the same file. Is there any simpler way of specifying this other that defining two diferent appenders.

标签: java log4j
0条回答
登录 后发表回答