log4j2.properties日志过滤

使用properties过滤日志.只打印一种信息

# 这个用于设置log4j2自身内部的信息输出,可以不设置,当设置成trace时,会看到log4j2内部各种详细输出
status = error
dest = err
name = PropertiesConfig

#公共变量
#文件路径
property.filePath=logs
property.filePattern=logs/%d{yyyy}/%d{MM}
#输出格式
property.layoutPattern=%-d{yyyy-MM-dd HH:mm:ss} [ %p ] [ %c ] %m%n

# 级别过滤(过滤日志记录)
#filters = threshold
filter.threshold.type = ThresholdFilter
# 只记录debug级别以上的日志,大小写无关:(ALL<)TRACE<DEBUG<INFO<WARN<ERROR<FATAL(<OFF)
filter.threshold.level = debug

# 根记录器,所有记录器的父辈
rootLogger.level = debug


appender.console.type = Console
appender.console.name = STDOUT
appender.console.target = SYSTEM_OUT
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = ${layoutPattern}
rootLogger.appenderRef.stdout.ref = STDOUT


appender.D.type = RollingFile
appender.D.name = DebugRollingFile
appender.D.fileName = ${filePath}/opdata-debug.log
appender.D.filePattern = ${filePattern}/opdata_debug.log
appender.D.layout.type = PatternLayout
appender.D.layout.pattern = ${layoutPattern}
appender.D.policies.type = Policies
appender.D.policies.time.type = TimeBasedTriggeringPolicy
appender.D.policies.time.interval = 1
appender.D.policies.time.modulate = true
appender.D.policies.size.type = SizeBasedTriggeringPolicy
appender.D.policies.size.size=20M
appender.D.strategy.type = DefaultRolloverStrategy
appender.D.strategy.max = 100
#过滤debug以上信息
appender.D.filter.threshold.type = ThresholdFilter
appender.D.filter.threshold.level = INFO
appender.D.filter.threshold.onMatch = DENY
appender.D.filter.threshold.onMisMatch=NEUTRAL

rootLogger.appenderRef.D.ref=DebugRollingFile
rootLogger.appenderRef.D.level=debug

appender.I.type = RollingFile
appender.I.name = InfoRollingFile
appender.I.fileName = ${filePath}/opdata-info.log
appender.I.filePattern = ${filePattern}/opdata_info.log
appender.I.layout.type = PatternLayout
appender.I.layout.pattern = ${layoutPattern}
appender.I.policies.type = Policies
appender.I.policies.time.type = TimeBasedTriggeringPolicy
appender.I.policies.time.interval = 1
appender.I.policies.time.modulate = true
appender.I.policies.size.type = SizeBasedTriggeringPolicy
appender.I.policies.size.size=20M
appender.I.strategy.type = DefaultRolloverStrategy
appender.I.strategy.max = 100
#过滤INFO以上信息
appender.I.filter.threshold.type = ThresholdFilter
appender.I.filter.threshold.level = WARN
appender.I.filter.threshold.onMatch = DENY
appender.I.filter.threshold.onMisMatch=NEUTRAL

rootLogger.appenderRef.I.ref = InfoRollingFile
rootLogger.appenderRef.I.level=INFO

appender.W.type = RollingFile
appender.W.name = WarnRollingFile
appender.W.fileName = ${filePath}/opdata-warn.log
appender.W.filePattern = ${filePattern}/opdata_warn.log
appender.W.layout.type = PatternLayout
appender.W.layout.pattern = ${layoutPattern}
appender.W.policies.type = Policies
appender.W.policies.time.type = TimeBasedTriggeringPolicy
appender.W.policies.time.interval = 1
appender.W.policies.time.modulate = true
appender.W.policies.size.type = SizeBasedTriggeringPolicy
appender.W.policies.size.size=20M
appender.W.strategy.type = DefaultRolloverStrategy
appender.W.strategy.max = 100
#过滤warn以上信息
appender.W.filter.threshold.type = ThresholdFilter
appender.W.filter.threshold.level = ERROR
appender.W.filter.threshold.onMatch = DENY
appender.W.filter.threshold.onMisMatch=NEUTRAL

rootLogger.appenderRef.W.ref = WarnRollingFile
rootLogger.appenderRef.W.level=WARN

appender.E.type = RollingFile
appender.E.name = ErrorRollingFile
appender.E.fileName = ${filePath}/opdata-error.log
appender.E.filePattern = ${filePattern}/opdata_error.log
appender.E.layout.type = PatternLayout
appender.E.layout.pattern = ${layoutPattern}
appender.E.policies.type = Policies
appender.E.policies.time.type = TimeBasedTriggeringPolicy
appender.E.policies.time.interval = 1
appender.E.policies.time.modulate = true
appender.E.policies.size.type = SizeBasedTriggeringPolicy
appender.E.policies.size.size=20M
appender.E.strategy.type = DefaultRolloverStrategy
appender.E.strategy.max = 100
#过滤ERROR以上信息
appender.E.filter.threshold.type = ThresholdFilter
appender.E.filter.threshold.level = FATAL
appender.E.filter.threshold.onMatch = DENY
appender.E.filter.threshold.onMisMatch=NEUTRAL

rootLogger.appenderRef.E.ref = ErrorRollingFile
rootLogger.appenderRef.E.level=ERROR

appender.F.type = RollingFile
appender.F.name = FatalRollingFile
appender.F.fileName = ${filePath}/opdata-fatal.log
appender.F.filePattern = ${filePattern}/opdata_fatal.log
appender.F.layout.type = PatternLayout
appender.F.layout.pattern = ${layoutPattern}
appender.F.policies.type = Policies
appender.F.policies.time.type = TimeBasedTriggeringPolicy
appender.F.policies.time.interval = 1
appender.F.policies.time.modulate = true
appender.F.policies.size.type = SizeBasedTriggeringPolicy
appender.F.policies.size.size=20M
appender.F.strategy.type = DefaultRolloverStrategy
appender.F.strategy.max = 100

rootLogger.appenderRef.F.ref = FatalRollingFile
rootLogger.appenderRef.F.level=FATAL

#appender.S.type = Socket
#appender.S.name= SocketTCP
#appender.S.host = 10.10.1.169
#appender.S.port=4560
#appender.S.protocol = TCP
#appender.S.layout.type = JsonLayout
#appender.S.layout.compact = true
#appender.S.layout.eventEol = true
#appender.S.connectTimeoutMillis = 2000
#rootLogger.appenderRef.S.ref=SocketTCP
#rootLogger.appenderRef.S.level=socket






#配置第三方包的日志
logger.jpath.name=com.jayway.jsonpath
logger.jpath.level=error

logger.mongodb.name=org.mongodb.driver
logger.mongodb.level=error

阅读更多
想对作者说点什么?

博主推荐

换一批

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