Reputation: 737
We are migrating from log4j 1.x to log4j 2.x and the configuration file format has changed significantly. Currently, we have these filters on one of our appenders:
<filter class="org.apache.log4j.filter.ExpressionFilter">
<param name="Expression" value="EXCEPTION ~= 'HTTP upgrade is not supported by the AJP protocol'" />
<param name="AcceptOnMatch" value="false"/>
</filter>
<filter class="org.apache.log4j.filter.ExpressionFilter">
<param name="Expression" value="CLASS ~= 'org.atmosphere.container.JSR356Endpoint'" />
<param name="AcceptOnMatch" value="false"/>
</filter>
These are intended to hide these two types of messages from the log; the first by the content of the reason of the exception thrown, and the second by the class of the logger. In the case of the latter, I know it seems like we could have just set a Logger
config class for this class and turn it off, but this didn't work -- perhaps this third-party class is overriding the log configuration at runtime.
In any case, I'm trying to figure out how to migrate these to log4j2, as there no longer appears to be an ExpressionFilter
. Your help is appreciated!
Thanks.
Upvotes: 4
Views: 1918
Reputation: 5813
For filtering first type of message i.e. filtering by content, you can use RegexFilter -
<Filters>
<RegexFilter regex="(?s).*?HTTP upgrade is not supported by the AJP protocol.*?" onMatch="DENY" onMismatch="ACCEPT" />
</Filters>
For filtering second type i.e. filtering by type, you can configure Logger
for turning off the logging of this class -
<Logger name="org.atmosphere.container.JSR356Endpoint" level="OFF" additivity="false">
<!--Write loggers here-->
</Logger>
Upvotes: 4