[ 
https://issues.apache.org/jira/browse/LOG4J2-3426?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17502765#comment-17502765
 ] 

Pooja Pandey commented on LOG4J2-3426:
--------------------------------------

[~pkarwasz],

 

This fixes the issue, thank you so much. Closing the issue. Any idea when 
2.17.3 would be released??

 

> 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.17.3
>
>
> 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.1#820001)

Reply via email to