Re: java.lang.ClassCastException: org.apache.log4j.bridge.AppenderWrapper cannot be cast to org.apache.log4j.FileAppender

"Piotr P. Karwasz" <[email protected]>
Newsgroups gmane.comp.jakarta.log4j.user
Message-ID <CAFmygFbtURrr8yKRZAoHb+_COjmG2qoM6XB5XSxTQrhJ7H-eoA@mail.gmail.com>
Ralph,

On Sat, Mar 5, 2022 at 6:21 PM Ralph Goers <[email protected]> wrote:
> Even if getAppender() were to bypass the AppenderWrapper it would still return
> org.apache.logging.log4j.core.appender.FileAppender, not org.apache.log4j.FileAppender.
> Are you proposing that getAppender return a proxy for org.apache.log4j.FileAppender?

No, my proposition doesn't apply to this case. If a user wants to use
a standard Log4j 1.x appender, he should get an AppenderWrapper of the
corresponding Log4j 2.x appender: the Log4j 1.x emulation must have
its limits.

However if a user wants to use a custom appender extending
`org.apache.log4j.FileAppender`, then `getAppender` returns an
AppenderWrapper of an AppenderAdapter of the custom appender.
Converting back and forth between Log4j 1.x appenders and Log4j 2.x
appenders is a little bit too much. `getAppender` should just return
the custom appender.

Piotr
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.