Log4j2中properties配置文件

原工作组比较清闲,被临时借调到新的工作组。组长给了个任务是把Log4j的XML配置文件改成properties,原因是XML格式的看着不舒服。哈,以上不算吐槽,只是交待一下,为什么我要这么费劲的使用properties做配置文件。

Log4j2 一开始抛弃了properties配置文件格式,到2.4版本时,又开始支持properties配置文件格式。到2.6版本又有新的要求。我用的是写本文时的最近版本2.8

status = error

property.LOG_HOME=/output/logs
property.BACKUP_HOME=backup
property.SERVER_NAME=buddie-Service
property.EVERY_FILE_SIZE=10M
property.OUTPUT_LOG_LEVEL=INFO
property.FILE_MAX=10

appender.console.type = Console
appender.console.name = STDOUT
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %m%n

appender.rolling.type=RollingFile
appender.rolling.name=RollingFileAll
appender.rolling.filter.threshold.level = trace
appender.rolling.filter.threshold.type = ThresholdFilter
appender.rolling.fileName=${LOG_HOME}/dev_${SERVER_NAME}_all.log
appender.rolling.filePattern=${LOG_HOME}/dev_${BACKUP_HOME}/dev_${SERVER_NAME}_all.%d{yyyy-MM-dd-HH}.log
appender.rolling.layout.type=PatternLayout
appender.rolling.layout.pattern=%d %p %C{1.} [%t] %m%n
appender.rolling.policies.type=Policies
appender.rolling.policies.time.type=TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval=2
appender.rolling.policies.time.modulate=true
appender.rolling.policies.size.type=SizeBasedTriggeringPolicy
appender.rolling.policies.size.size=${EVERY_FILE_SIZE}
appender.rolling.strategy.type=DefaultRolloverStrategy

appender.error.type=RollingFile
appender.error.name=RollingFileError
appender.error.filter.threshold.level = error
appender.error.filter.threshold.type = ThresholdFilter
appender.error.fileName=${LOG_HOME}/dev_${SERVER_NAME}_error.log
appender.error.filePattern=${LOG_HOME}/dev_${BACKUP_HOME}/dev_${SERVER_NAME}_error.%d{yyyy-MM-dd-HH}.log
appender.error.layout.type=PatternLayout
appender.error.layout.pattern=%d %p %C{1.} [%t] %m%n
appender.error.policies.type=Policies
appender.error.policies.time.type=TimeBasedTriggeringPolicy
appender.error.policies.time.interval=2
appender.error.policies.time.modulate=true
appender.error.policies.size.type=SizeBasedTriggeringPolicy
appender.error.policies.size.size=${EVERY_FILE_SIZE}
appender.error.strategy.type=DefaultRolloverStrategy

appender.charge.type=RollingFile
appender.charge.name=RollingFileCharge
appender.charge.filter.threshold.level = trace
appender.charge.filter.threshold.type = ThresholdFilter
appender.charge.fileName=${LOG_HOME}/dev_${SERVER_NAME}_charge.log
appender.charge.filePattern=${LOG_HOME}/dev_${BACKUP_HOME}/dev_${SERVER_NAME}_charge.%d{yyyy-MM-dd-HH}.log
appender.charge.layout.type=PatternLayout
appender.charge.layout.pattern=%d %p %C{1.} [%t] %m%n
appender.charge.policies.type=Policies
appender.charge.policies.time.type=TimeBasedTriggeringPolicy
appender.charge.policies.time.interval=2
appender.charge.policies.time.modulate=true
appender.charge.policies.size.type=SizeBasedTriggeringPolicy
appender.charge.policies.size.size=${EVERY_FILE_SIZE}
appender.charge.strategy.type=DefaultRolloverStrategy

logger.activity.name = buddie.activity
logger.activity.level = debug
logger.activity.additivity = false
logger.activity.appenderRef.all.ref = RollingFileAll
logger.activity.appenderRef.error.ref = RollingFileError
logger.activity.appenderRef.stdout.ref = STDOUT

logger.login.name = buddie.login
logger.login.level = debug
logger.login.additivity = false
logger.login.appenderRef.all.ref = RollingFileAll
logger.login.appenderRef.error.ref = RollingFileError
logger.login.appenderRef.stdout.ref = STDOUT

logger.charge.name = buddie.charge
logger.charge.level = trace
logger.charge.additivity = false
logger.charge.appenderRef.all.ref = RollingFileAll
logger.charge.appenderRef.error.ref = RollingFileError
logger.charge.appenderRef.charge.ref = RollingFileCharge
logger.charge.appenderRef.stdout.ref = STDOUT

rootLogger.level = info
rootLogger.appenderRef.stdout.ref = STDOUT
rootLogger.appenderRef.all.ref = RollingFileAll
rootLogger.appenderRef.error.ref = RollingFileError

 

展开阅读全文

没有更多推荐了,返回首页