You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Volkan Yazici (Jira)" <ji...@apache.org> on 2022/05/02 21:12:00 UTC

[jira] [Updated] (LOG4J2-3426) Log4j 1.x bridge Logger.getAppender returns a wrapped AppenderAdapter

     [ https://issues.apache.org/jira/browse/LOG4J2-3426?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Volkan Yazici updated LOG4J2-3426:
----------------------------------
    Fix Version/s: 2.18.0
                       (was: 2.17.3)

> Log4j 1.x bridge Logger.getAppender returns a wrapped AppenderAdapter
> ---------------------------------------------------------------------
>
>                 Key: LOG4J2-3426
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3426
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Log4j 1.2 bridge
>    Affects Versions: 2.17.2
>            Reporter: Pooja Pandey
>            Assignee: Piotr Karwasz
>            Priority: Major
>             Fix For: 2.18.0
>
>
> In our code, we have a custom logger and a custom multiprocess rolling FileAppender as below shown in below code snippet.
>  
> For some processing, we need to get appender from logger, so we call Logger.getAppender() but with log4j1.x bridge it is returning AppenderWrapper unlike log4j1.x where we used to get an Appender.
>  
> We need to typecast returned value to FileAppender but since now it AppenderWrapper, so it is throwing exception "java.lang.ClassCastException: org.apache.log4j.bridge.AppenderWrapper cannot be cast to org.apache.log4j.FileAppender".
> To fix cast exception we are overriding getAppender in our customLogger as shown below, however we are still having some minor issues in reading property value but may be this new issue is due to some other problems. I am still trying to figure out.
> I am creating this Jira ticket with a hope that if there is a possibility then may be log4j1.x bridge can be modified to provide this conversion instead we override this method in our custom logger.
> @Override    public Appender getAppender(final String name) \{        AppenderWrapper appenderWrapper = (AppenderWrapper) super.getAppender(name);        return ((AppenderAdapter.Adapter)appenderWrapper.getAppender()).getAppender();    }
>  
> public class CustomLogger extends Logger implements java.io.Serializable {}
>  
> public class CustomMultiProcessRollingAppender extends FileAppender \{ }



--
This message was sent by Atlassian Jira
(v8.20.7#820007)