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

Gary Gregory <[email protected]>
Newsgroups gmane.comp.jakarta.log4j.user
Message-ID <CACZkXPy-FuPNGxmroCiW8rh1pnG6Km0GyQurzXqAOLnRVA6-xw@mail.gmail.com>
This is a bit tricky, the API is typed to return an Appender and that's
what we do, not only that but it is an Appender that behaves properly IIRC.
If we returned the wrapped Log4j 1 Appender and you call it, the wrong
thing will happen IIRC.

Gary

On Sat, Mar 5, 2022, 15:02 Piotr P. Karwasz <[email protected]> wrote:

> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
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.