本文介绍了Log4j StringMatchFilter和denyAll过滤器属性配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以让我知道软件包的过滤器属性吗?我想将日志分成两个不同的日志文件.以下是我尝试使用的配置,但它不起作用.我想拒绝日志基于字符串,例如"UserMgmt-",并允许在log1附加程序中允许休息日志,仅允许log2附加器允许"UserMgmt-",并拒绝休息允许日志.

Can anyone please let me know filter properties for a package whereI want to separate the logs in two different logs files. Below is the configuration which I am trying use but its not working. I want deny logsbased string like 'UserMgmt-' and allow rest logs in log1 appender and allow only log2 appender allow 'UserMgmt-' and deny rest allow logs.

log4j.logger.com.abc=DEBUG, log1
log4j.logger.com.abc=DEBUG, log2


log4j.appender.log1=org.apache.log4j.RollingFileAppender
log4j.appender.log1.Append=true
log4j.appender.log1.File=C:/Oracle/Middleware/user_projects/domains/logs/G_loAFg/UM.log
log4j.appender.log1.layout=org.apache.log4j.PatternLayout
log4j.appender.log1.layout.ConversionPattern=%d %-6p [%c] %m%n
log4j.appender.log1.filter.1=org.apache.log4j.varia.StringMatchFilter
log4j.appender.log1.filter.1.StringToMatch=UserMgmt-
log4j.appender.log1.filter.1.AcceptOnMatch=false

log4j.appender.log2=org.apache.log4j.RollingFileAppender
log4j.appender.log2.Append=true
log4j.appender.log2.File=C:/Oracle/Middleware/user_projects/domains/logs/PM.log
log4j.appender.log2.layout=org.apache.log4j.PatternLayout
log4j.appender.log2.layout.ConversionPattern=%d %-6p [%c] %m%n
log4j.appender.log2.filter.1=org.apache.log4j.varia.StringMatchFilter
log4j.appender.log2.filter.1.StringToMatch=UserMgmt-
log4j.appender.log2.filter.1.AcceptOnMatch=true

推荐答案

添加了第一个log1后可以拒绝所有过滤器的功能

Added deny all filter in 1st log1 after that it worked

log4j.appender.log1.filter=org.apache.log4j.varia.DenyAllFilter


log4j.logger.com.abc=DEBUG, log1
log4j.logger.com.abc=DEBUG, log2


log4j.appender.log1=org.apache.log4j.RollingFileAppender
log4j.appender.log1.Append=true
log4j.appender.log1.File=C:/Oracle/Middleware/user_projects/domains/logs/G_loAFg/UM.log
log4j.appender.log1.layout=org.apache.log4j.PatternLayout
log4j.appender.log1.layout.ConversionPattern=%d %-6p [%c] %m%n
log4j.appender.log1.filter.1=org.apache.log4j.varia.StringMatchFilter
log4j.appender.log1.filter.1.StringToMatch=UserMgmt-
log4j.appender.log1.filter.1.AcceptOnMatch=false
log4j.appender.log1.filter=org.apache.log4j.varia.DenyAllFilter
log4j.appender.log2=org.apache.log4j.RollingFileAppender
log4j.appender.log2.Append=true
log4j.appender.log2.File=C:/Oracle/Middleware/user_projects/domains/logs/PM.log
log4j.appender.log2.layout=org.apache.log4j.PatternLayout
log4j.appender.log2.layout.ConversionPattern=%d %-6p [%c] %m%n
log4j.appender.log2.filter.1=org.apache.log4j.varia.StringMatchFilter
log4j.appender.log2.filter.1.StringToMatch=UserMgmt-
log4j.appender.log2.filter.1.AcceptOnMatch=true

这篇关于Log4j StringMatchFilter和denyAll过滤器属性配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 07:15