<?xml version="1.0" encoding="UTF-8" ?>Then run the following to test:
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p - %m%n" />
</layout>
<filter class="org.apache.log4j.varia.StringMatchFilter">
<param name="StringToMatch" value="the-text-not-to-log" />
<param name="AcceptOnMatch" value="false" />
</filter>
<!-- <filter class="org.apache.log4j.varia.DenyAllFilter" /> -->
</appender>
<root>
<priority value="info" />
<appender-ref ref="console" />
</root>
</log4j:configuration>
LOG.info("This is an info and shouldn't be logged with the-text-not-to-log and blah blah");
LOG.info("This is logged");
LOG.debug("This is a debug and not logged");
LOG.error("This is an error and logged");
If you only want to log some text, then change the value for AcceptOnMatch to true and add DenyAllFilter.
Thank you, this worked for me!!
ReplyDelete