Using CompositeFilter on appender with properties configuration

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Using CompositeFilter on appender with properties configuration

Oliver Limberg
Hi,

I am trying to configure a RegexFilter and and ThresholdFilter together on
an appender.
According to the documentation this should be pretty simple for XML
configuration.
However, the project currently uses the properties format and the example
does not contain the usage of CompositeFilter.
Hier are various attempts I tried:

appender.console.type = Console
appender.console.name = Console
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = ${log4j2.out.pattern}
appender.console.filter.c.type = CompositeFilter
appender.console.filter.c.regex.type = RegexFilter
appender.console.filter.c.regex.regex = expected resource not found:
/META-INF/javamail.default.(providers|address.map)
appender.console.filter.c.regex.onMatch = DENY
appender.console.filter.c.threshold.type = ThresholdFilter
appender.console.filter.c.threshold.level = WARN

appender.console.type = Console
appender.console.name = Console
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = ${log4j2.out.pattern}
appender.console.filters.c.type = CompositeFilter
appender.console.filters.c.filter.regex.type = RegexFilter
appender.console.filters.c.filter.regex.regex = expected resource not
found: /META-INF/javamail.default.(providers|address.map)
appender.console.filters.c.filter.regex.onMatch = DENY
appender.console.filters.c.filter.threshold.type = ThresholdFilter
appender.console.filters.c.filter.threshold.level = WARN

appender.console.type = Console
appender.console.name = Console
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = ${log4j2.out.pattern}
appender.console.filters.regex.type = RegexFilter
appender.console.filters.regex.regex = expected resource not found:
/META-INF/javamail.default.(providers|address.map)
appender.console.filters.regex.onMatch = DENY
appender.console.filters.threshold.type = ThresholdFilter
appender.console.filters.threshold.level = WARN


Looking at the source code, the keyword filters is only allowed at top
level and expects a comma separated lists of values.
But what should you put as values? Further more, as far as I understood,
those filters will be context-wide filters and will not be passed to the
loggers in case of a DENY.
I also tried to configure the single filter on an appender as
CompositeFilter and then add the specific filters to it, but this did not
work either. So any help would be appreciated.

Regards
Oliver
Reply | Threaded
Open this post in threaded view
|

Re: Using CompositeFilter on appender with properties configuration

Oliver Limberg
I finally had time to look into this again and managed to find a solution:

The type one has to use for a CompositeFilter is ‘filters’.
Afterwards you just specify the various filters below the same key.
Here a working example of a CompositeFilter on an appender:

appender.console.type = Console
appender.console.name = Console
appender.console.target = SYSTEM_OUT
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %d [%t] %-5level: %msg%n%throwable
appender.console.filter.composite.type = filters
appender.console.filter.composite.threshold.type = ThresholdFilter
appender.console.filter.composite.threshold.level = WARN
appender.console.filter.composite.regex.type = RegexFilter
appender.console.filter.composite.regex.regex = expected resource not found: /META-INF/javamail\\.default\\.(providers|address\\.map)
appender.console.filter.composite.regex.onMatch = DENY
appender.console.filter.composite.regex.onMismatch = NEUTRAL
Best Regards
Oliver


On 2020/02/18 11:19:52, Oliver Limberg <[hidden email]> wrote:

> Hi,
>
> I am trying to configure a RegexFilter and and ThresholdFilter together on
> an appender.
> According to the documentation this should be pretty simple for XML
> configuration.
> However, the project currently uses the properties format and the example
> does not contain the usage of CompositeFilter.
> Hier are various attempts I tried:
>
> appender.console.type = Console
> appender.console.name = Console
> appender.console.layout.type = PatternLayout
> appender.console.layout.pattern = ${log4j2.out.pattern}
> appender.console.filter.c.type = CompositeFilter
> appender.console.filter.c.regex.type = RegexFilter
> appender.console.filter.c.regex.regex = expected resource not found:
> /META-INF/javamail.default.(providers|address.map)
> appender.console.filter.c.regex.onMatch = DENY
> appender.console.filter.c.threshold.type = ThresholdFilter
> appender.console.filter.c.threshold.level = WARN
>
> appender.console.type = Console
> appender.console.name = Console
> appender.console.layout.type = PatternLayout
> appender.console.layout.pattern = ${log4j2.out.pattern}
> appender.console.filters.c.type = CompositeFilter
> appender.console.filters.c.filter.regex.type = RegexFilter
> appender.console.filters.c.filter.regex.regex = expected resource not
> found: /META-INF/javamail.default.(providers|address.map)
> appender.console.filters.c.filter.regex.onMatch = DENY
> appender.console.filters.c.filter.threshold.type = ThresholdFilter
> appender.console.filters.c.filter.threshold.level = WARN
>
> appender.console.type = Console
> appender.console.name = Console
> appender.console.layout.type = PatternLayout
> appender.console.layout.pattern = ${log4j2.out.pattern}
> appender.console.filters.regex.type = RegexFilter
> appender.console.filters.regex.regex = expected resource not found:
> /META-INF/javamail.default.(providers|address.map)
> appender.console.filters.regex.onMatch = DENY
> appender.console.filters.threshold.type = ThresholdFilter
> appender.console.filters.threshold.level = WARN
>
>
> Looking at the source code, the keyword filters is only allowed at top
> level and expects a comma separated lists of values.
> But what should you put as values? Further more, as far as I understood,
> those filters will be context-wide filters and will not be passed to the
> loggers in case of a DENY.
> I also tried to configure the single filter on an appender as
> CompositeFilter and then add the specific filters to it, but this did not
> work either. So any help would be appreciated.
>
> Regards
> Oliver
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]