0

My application uses log4j for Logging and it's deployed in WebSphere Application Server V7. Log4j jars are included in WEB-INF/lib, and the log4j.properties file is located externally and loaded throgh org.springframework.util.Log4jConfigurer. Currently, the Log configuration is the following:

log4j.logger.com.myapp=DEBUG, InfoAppender, DebugAppender

log4j.appender.InfoAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.InfoAppender.Threshold=INFO
log4j.appender.InfoAppender.File=/home/infoFile.log
log4j.appender.InfoAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.InfoAppender.layout.ConversionPattern=%d %p [%c] - %m%n

log4j.appender.DebugAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.DebugAppender.Threshold=DEBUG
log4j.appender.DebugAppender.File=/home/debugFile.log
log4j.appender.DebugAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.DebugAppender.layout.ConversionPattern=%d %p [%c] - %m%n

Logging works as expected and the files infoFile.log and debugFile.log are populated correctly. But also, all the lines that are sent to these files are also written in SystemOut.log file on the server, with many other messages from the runtime.

We have many WAR files with this configuration, so the SystemOut.log file is getting pretty big very soon, and its getting hard to find logs related to the runtime environment. Is there a way to exclude the messages that are written to infoFile.log and debugFile.log from SystemOut.log?

4

1 回答 1

0

为了避免传播到SystemOut.log,只需将记录器的可加性属性设置为 false。为此,我们将此行添加到log4j.properties.

log4j.additivity.com.myapp=false
于 2013-08-06T19:09:16.650 回答