2
我正在嘗試使用屬性文件配置log4j2。我需要有多個滾動文件appender才能登錄多個文件。但我似乎無法獲得多個滾動文件appender的工作。當我只使用一個滾動文件appender時,它似乎工作正常,並生成相應的日誌文件。在多個appender的情況下,只有root logger正在生成日誌文件。配置log4j2.properties時多個滾動文件appender不起作用
我現在的配置是: -
name = PropertiesConfig
status = warn
property.log-path = E:/logs
appenders = rolling
appender.rolling.type = RollingFile
appender.rolling.name = rolAppender1
appender.rolling.fileName = ${log-path}/log1.log
appender.rolling.filePattern = ${log-path}/$${date:yyyy-MM}/Log-%d{dd-MMM-yyyy}-log1.log
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = %d{yyyy-MMM-dd - HH:mm} [%-p] %C{1}.%M(%F:%L)-:%m%n
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 1
appender.rolling.policies.time.modulate = false
appender.rolling.type = RollingFile
appender.rolling.name = rolAppender2
appender.rolling.fileName = ${log-path}/log2.log
appender.rolling.filePattern = ${log-path}/$${date:yyyy-MM}/Log-%d{dd-MMM-yyyy}.log
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = %d{yyyy-MMM-dd - HH:mm} [%-p] %C{1}.%M(%F:%L)-:%m%n
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 1
appender.rolling.policies.time.modulate = false
appender.rolling.type = RollingFile
appender.rolling.name = rolAppender3
appender.rolling.fileName = ${log-path}/log3.log
appender.rolling.filePattern = ${log-path}/$${date:yyyy-MM}/Log-%d{dd-MMM-yyyy}-log3.log
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = %d{yyyy-MMM-dd - HH:mm} [%-p] %C{1}.%M(%F:%L)-:%m%n
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 1
appender.rolling.policies.time.modulate = false
appender.rolling.type = RollingFile
appender.rolling.name = rolAppender4
appender.rolling.fileName = ${log-path}/log4.log
appender.rolling.filePattern = ${log-path}/$${date:yyyy-MM}/Log-%d{dd-MMM-yyyy}-log4.log
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = %d{yyyy-MMM-dd - HH:mm} [%-p] %C{1}.%M(%F:%L)-:%m%n
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 1
appender.rolling.policies.time.modulate = false
appender.rolling.type = RollingFile
appender.rolling.name = rolAppender5
appender.rolling.fileName = ${log-path}/log5.log
appender.rolling.filePattern = ${log-path}/$${date:yyyy-MM}/Log-%d{dd-MMM-yyyy}-log5.log
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = %d{yyyy-MMM-dd - HH:mm} [%-p] %C{1}.%M(%F:%L)-:%m%n
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 1
appender.rolling.policies.time.modulate = false
appender.rolling.type = RollingFile
appender.rolling.name = rolAppender6
appender.rolling.fileName = ${log-path}/log6.log
appender.rolling.filePattern = ${log-path}/$${date:yyyy-MM}/Log-%d{dd-MMM-yyyy}-log6.log
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = %d{yyyy-MMM-dd - HH:mm} [%-p] %C{1}.%M(%F:%L)-:%m%n
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 1
appender.rolling.policies.time.modulate = false
appender.rolling.type = RollingFile
appender.rolling.name = rolAppender7
appender.rolling.fileName = ${log-path}/log7.log
appender.rolling.filePattern = ${log-path}/$${date:yyyy-MM}/Log-%d{dd-MMM-yyyy}-log7.log
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = %d{yyyy-MMM-dd - HH:mm} [%-p] %C{1}.%M(%F:%L)-:%m%n
appender.rolling.policies.type=Policies
appender.rolling.policies.time.type=TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 1
appender.rolling.policies.time.modulate = false
appender.rolling.type = RollingFile
appender.rolling.name = rolAppender8
appender.rolling.fileName = ${log-path}/log8.log
appender.rolling.filePattern = {log-path}/$${date:yyyy-MM}/Log-%d{dd-MMM-yyyy}-log8.log
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = %d{yyyy-MMM-dd - HH:mm} [%-p] %C{1}.%M(%F:%L)-:%m%n
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 1
appender.rolling.policies.time.modulate = false
loggers = rolling
logger.rolling.name = org.springframework
logger.rolling.level = fatal
logger.rolling.name = logger1
logger.rolling.level = info
logger.rolling.additivity = false
logger.rolling.appenderRef.rolling.ref = rolAppender1
logger.rolling.name = logger2
logger.rolling.level = info
logger.rolling.additivity = false
logger.rolling.appenderRef.rolling.ref = rolAppender2
logger.rolling.name = logger3
logger.rolling.level = info
logger.rlolling.additivity = false
logger.rolling.appenderRef.rolling.ref = rolAppender3
logger.rolling.name = logger4
logger.rolling.level = info
logger.rolling.additivity = false
logger.rolling.appenderRef.rolling.ref = rolAppender4
logger.rolling.name = logger5
logger.rolling.level = info
logger.rolling.additivity = false
logger.rolling.appenderRef.rolling.ref = rolAppender5
logger.rolling.name = logger6
logger.rolling.level = info
logger.rolling.additivity = false
logger.rolling.appenderRef.rolling.ref = rolAppender6
logger.rolling.name = logger7
logger.rolling.level = info
logger.rolling.additivity = false
logger.rolling.appenderRef.rolling.ref = rolAppender7
rootLogger.level = info
rootLogger.appenderRefs = f
rootLogger.appenderRef.f.ref = rolAppender8
我是新來log4j2不很瞭解。任何幫助,將不勝感激。