0

在我们的集群项目中,我们有 2 台机器,每台机器都有 3 个基于 Weblogic Server 8.1 上的 Spring MVC 1.2.8、Log4J 1.2 和 JDK 1.4 的 Web 应用程序实例。每台机器都有一个日志位置。3 个实例写入同一个文件。

一位系统管理员意识到,在日志文件旋转后,应用程序会同时写入旋转文件和原始文件。

有什么问题?

这是我们的 Log4J.xml 配置:

#----------------------------------------------------------
#
# Set root logger levels and attach appenders
#
#----------------------------------------------------------

log4j.rootLogger=WARN

#----------------------------------------------------------
#
# Define and configure appenders
#
#----------------------------------------------------------

log4j.appender.MY_CONSOLE_1 = org.apache.log4j.ConsoleAppender
log4j.appender.MY_CONSOLE_1.layout = org.apache.log4j.PatternLayout
log4j.appender.MY_CONSOLE_1.layout.ConversionPattern = %-5p %c{2} %x - %m%n

log4j.appender.MY_LOG_FILE_1 = org.apache.log4j.RollingFileAppender
log4j.appender.MY_LOG_FILE_1.File = /logs/appdomain/application/application.log
log4j.appender.MY_LOG_FILE_1.MaxFileSize = 10000KB

log4j.appender.sendFile = org.apache.log4j.DailyRollingFileAppender
log4j.appender.sendFile.File = /logs/appdomain/application/WS.log
log4j.appender.sendFile.DatePattern = '.'yyyy-MM-dd
log4j.appender.sendFile.layout = org.apache.log4j.PatternLayout
log4j.appender.sendFile.layout.ConversionPattern = %m%n

# Keep one backup file
log4j.appender.MY_LOG_FILE_1.MaxBackupIndex = 10
log4j.appender.MY_LOG_FILE_1.layout = org.apache.log4j.PatternLayout
log4j.appender.MY_LOG_FILE_1.layout.ConversionPattern = %p %d %c - %m%n

#----------------------------------------------------------
#
# Attach appenders and set trace levels for each base
# package. Siblings will inherit appenders and trace level.
#
#----------------------------------------------------------

log4j.category.com = WARN, MY_CONSOLE_1
#------------------------------------------------------------
# to avoid duplicate logging
#------------------------------------------------------------
log4j.additivity.com=false
log4j.category.jsp = WARN, MY_CONSOLE_1
log4j.category.applicationException = WARN, MY_CONSOLE_1, MY_LOG_FILE_1



#----------------------------------------------------------
#
# Overide trace levels for individual sub-packages of
# interest.
#
#----------------------------------------------------------

log4j.category.com.application = WARN,  MY_LOG_FILE_1
log4j.category.WSLOG = INFO,sendFile
log4j.category.org.apache.axis = WARN,MY_LOG_FILE_1
4

0 回答 0