java - log4j StringMatchFilter configuration -
i want log message containing "here debug" log4j2.xml this:
<appenders> <!-- console appender --> <console name="console" target="system_out"> <patternlayout pattern="%-5p %c{1} - %m%n" /> </console> <!--rollingfile appender--> <rollingfile name="rollingfile" filename="${sys:catalina.base}/logs/${project.name}.log" filepattern="${sys:catalina.base}/logs/${project.name}-%i.log"> <patternlayout> <pattern>%p %d{dd-mmmmmmmmm-yyyy hh:mm:ss:sss} %m %n%n</pattern> </patternlayout> <policies> <sizebasedtriggeringpolicy size="500kb" /> </policies> <defaultrolloverstrategy max="5" /> </rollingfile> <filter class="org.apache.log4j.varia.stringmatchfilter"> <param name="stringtomatch" value="here debug" /> <param name="acceptonmatch" value="true" /> </filter> </appenders> <loggers> <root level="debug"> <!--appenderref ref="console" /--> <appenderref ref="rollingfile" /> </root> </loggers>
and java code : log.info("here debug"); log.info("xxxxxxxxxxxx"); log.warn("this warning"); log.error("this error"); still got in log.
ok figured out. log4j 1 , 2 different on configuration. in 2, filter should
Comments
Post a Comment