I also sent a message to the mailing list about this 4 days before:
https://lists.apache.org/thread/yoj9bdfqfph6q03t26r5mrdc37zjd9nw
but there's been no response yet.

For now I just started using %xEx, but I'd appreciate it if this feature
could be supported for %ex as well.

Thanks,
Damien

On Sun, Feb 13, 2022 at 6:40 PM Janaka Bandara <janakaud+apa...@gmail.com>
wrote:

> Hello everyone,
>
> PatternLayout (
> https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout)
> advertises this parameter syntax, to allow filtering undesired stack
> frames from logged stacktraces: `%ex{filters(package,list)}`
>
> > ex|exception|throwable
> >
> > {filters(package,package,...)}
> >
> > Use {filters(packages)} where packages is a list of package names to
> suppress matching stack frames from stack traces.
>
>
> However on 2.17.1 (latest) when I use such a pattern:
>
> `<PatternLayout pattern="%d{ISO8601} %5p %c{1} %m%n%ex{filters(org.p2)}"/>`
>
> no filtering happens, and I still get stacktraces like:
>
> ```
> 2022-02-14T07:25:23,048 ERROR TestLog error
> java.lang.IllegalStateException: Oh no
>         at org.p2.Foo.run(Foo.java:5)
>         at com.p1.Bar.run(Bar.java:7)
>         at org.p2.Bar.run(Bar.java:5)
>         at com.p1.Foo.run(Foo.java:7)
>         at TestLog.main(TestLog.java:11)
> ```
>
>
> Per my understanding, above config should remove the two `at
> org.p2...` frames/lines from the stacktrace.
>
> Turning off `alwaysWriteExceptions` makes no change.
>
>
> Looking at the
> `org.apache.logging.log4j.core.impl.ThrowableFormatOptions#newInstance(..)`
> codebase I see that the `filters` parameter is parsed and loaded to
> `ThrowableFormatOptions` properly; but in the actual
>
> `org.apache.logging.log4j.core.pattern.ThrowablePatternConverter#formatOption(..)`
> I cannot find any stack frame filtering logic using `filters` config.
> So to me it seems like `filters` functionality is not yet implemented
> (although I could not find any documentation/discussions to back my
> suspicion).
>
>
> I would be happy to contribute a filtering implementation honoring the
> already documented specification; however first I would like to
> confirm if I'm correct so far, or if I have missed something.
>
> TIA!
>
> --
> Janaka Bandara
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>
>

Reply via email to