0
我是Log4j2的新手,我無法理解如何在兩個appender中設置兩個不同的級別,例如我想在File.log
以上級別Error中寫入,並且在控制檯級別Debug之後,這裏是我的屬性文件:兩個appender中的不同級別log4j2.properties?
status = error
name = PropertiesConfig
property.filename = logs
appenders = console, rolling
appender.console.type = Console
appender.console.name = STDOUT
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n
appender.rolling.type = RollingFile
appender.rolling.name = RollingFile
appender.rolling.fileName = ${filename}/AndrewDebug-${date:yyyy-MM-dd}.log
appender.rolling.filePattern = debug-backup-%d{MM-dd-yy-HH-mm-ss}-%i.log.gz
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%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 = true
appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
appender.rolling.policies.size.size=10MB
appender.rolling.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.max = 20
logger.rolling.name = web.languages
logger.rolling.level = debug
logger.rolling.appenderRef.rolling.ref = RollingFile
rootLogger.level = debug
rootLogger.appenderRefs = stdout
rootLogger.appenderRef.stdout.ref = STDOUT
你嘗試使用logger.console.level =調試? – abstractnature
org.apache.logging.log4j.core.config.ConfigurationException:爲記錄器控制檯提供沒有名稱屬性 –