我正在构建一个应用程序,用新的log4jv2迁移旧的log4j。我有密码 log4j.properties
文件,然后我按照在线文档中的说明编写了代码。我已经设置了我的记录器,其中有2个linux框,每个框有2个 .log
文件夹。有一个循环赛,所以基本上四个之间可以去任何一个。最近我注意到,当新的一天来临时,它不会压缩box服务器上的4个日志文件。相反,我假设它只压缩前一天接触过的最后一个.log文件,而不是它应该如何工作的所有4个文件。所以,我的问题是,我想修复我的记录器,它正确地将每个框中的所有4个日志文件压缩。下面是我的设置和log4j.properties文件的示例:
linux方框1:
(logs)
mars_linux35a_s1.log
mars_linux35a_s2.log
linux方框2:
(logs)
mars_linux35b_s3.log
mars_linux35b_s4.log
log4j.属性:
status = TRACE
name= properties_configuration
# Give directory path where log files should get stored
property.basePath = ${sys:LOG_BASE}
# ConsoleAppender will print logs on console
appender.console.type = Console
appender.console.name = consoleLogger
appender.console.target = SYSTEM_OUT
appender.console.layout.type = PatternLayout
# Specify the pattern of the logs
appender.console.layout.pattern = %d{dd-MM-yyyy HH:mm:ss.SSS}.-%t-%x-%-5p-%-10c:%m%n
# MARS
# RollingFileAppender will print logs in file which can be rotated based on time or size
appender.rolling.type = RollingFile
appender.rolling.name = fileLoggerMARS
appender.rolling.fileName= /export/bea/mylogger/col5/MARS/mars_${sys:weblogic.Name}.log
appender.rolling.filePattern= /export/bea/mylogger/col5/MARS/mars_${sys:weblogic.Name}_%d{yyyy-MM-dd}.gz
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = %d{dd-MM-yyyy HH:mm:ss.SSS}.-%t-%x-%-5p-%-10c:%m%n
appender.rolling.policies.type = Policies
# Rotate log file each day and keep 14 days worth
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 1
appender.rolling.policies.time.modulate = true
appender.rolling.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.delete.type = Delete
appender.rolling.strategy.delete.basePath = /export/bea/mylogger/col5/MARS/
appender.rolling.strategy.delete.maxDepth = 1
appender.rolling.strategy.delete.ifLastModified.type = IfLastModified
# Delete files older than 14 days
appender.rolling.strategy.delete.ifLastModified.age = 14d
# Mention package name here in place of example. Classes in this package or subpackages will use ConsoleAppender and RollingFileAppender for logging
logger.MARSLogger.name = MARSLogger
logger.MARSLogger.level = debug
logger.MARSLogger.additivity = false
logger.MARSLogger.appenderRef.rolling.ref = fileLoggerMARS
logger.MARSLogger.appenderRef.console.ref = consoleLogger
# Configure root logger for logging error logs in classes which are in package other than above specified package
rootLogger.level = debug
rootLogger.additivity = false
rootLogger.appenderRef.rolling.ref = fileLoggerMARS
rootLogger.appenderRef.console.ref = consoleLogger
暂无答案!
目前还没有任何答案,快来回答吧!