Search code examples
logginglog4jlog4j2

How to convert log4j StringMatchFilter to log4j2?


I'm currently facing a problem to convert the StringMatchFilter from Log4j to Log4j2. I couldn't find any other filter in version 2, so I'm kinda stuck here.

log4j.appender.CONSOLE.filter.1=org.apache.log4j.varia.StringMatchFilter
log4j.appender.CONSOLE.filter.1.AcceptOnMatch=false
log4j.appender.CONSOLE.filter.1.StringToMatch=Could not remove JaloSession 
JaloSession

Solution

  • Try using MarkerFilter. MarkerFilter will do same job. Example:

    <Filters>
        <MarkerFilter marker="STR1" onMatch="DENY" onMismatch="NEUTRAL"/>
        <MarkerFilter marker="Str2" onMatch="DENY" onMismatch="NEUTRAL"/>
    </Filters>