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

Piotr Karwasz edited comment on LOG4J2-3499 at 5/4/22 9:50 PM:
---------------------------------------------------------------

Hello [~xb_apache_jira_user],

The Log4j 1.x bridge uses a set of builder plugins that convertd all standard 
Log4j 1.x appenders to their Log4j2 equivalents. The lack of a plugin for your 
custom appender is a perfectly normal condition (hence it is a warning, not an 
error) and the bridge falls back to instantiating your custom appender directly.

The reason your custom appender does not work must be different. Can you share 
its code for testing?

Remark that custom Log4j 1.x appenders are not officially supported by the 
bridge. While some are known to be working (e.g. the `RollingFileAppender` from 
Apache Extras) they are subject to all the limitations of the Log4j 1.x 
architecture (performance, lost messages during reconfiguration, deadlocks, 
etc.).

The usual advice is:
 # Look at the list of [Log4j2 native 
appenders|https://logging.apache.org/log4j/2.x/manual/appenders.html]. Often 
there is already an appender for your needs.
 # If you really need a custom appender, rewriting it directly for Log4j2 is a 
better solution than adapting it to work with the bridge.


was (Author: pkarwasz):
Hello [~xb_apache_jira_user],

The Log4j 1.x bridge uses a set of builder plugins that convert all standard 
Log4j 1.x appenders to their Log4j2 equivalents. The lack of a plugin for your 
custom appender is a perfectly normal condition (hence it is a warning, not an 
error) and the bridge falls back to instantiating your custom appender directly.

The reason your custom appender does not work must be different. Can you share 
its code for testing?

Remark that custom Log4j 1.x appenders are not officially supported by the 
bridge. While some are known to be working (e.g. the `RollingFileAppender` from 
Apache Extras) they are subject to all the limitations of the Log4j 1.x 
architecture (performance, lost messages during reconfiguration, deadlocks, 
etc.).

The usual advice is:
 # Look at the list of [Log4j2 native 
appenders|https://logging.apache.org/log4j/2.x/manual/appenders.html]. Often 
there is already an appender for your needs.
 # If you really need a custom appender, rewriting it directly for Log4j2 is a 
better solution than adapting it to work with the bridge.

> Bridge with log4j2 and log4j configuration cannot load custom appender class 
> due to using lower case key name
> -------------------------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-3499
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3499
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 2.17.2
>            Reporter: Xitiz Bhatia
>            Priority: Major
>              Labels: bridge, log4j-to-log4j2-bridge, log4j2
>
> Using log4j 1.x to log4j2 bridge with log4j2 2.17.2 and log4j properties, the 
> customer appender that was working in log4j stops working. Upon enabling 
> log4j debug logging, the message shown when processing the appender is:
> WARN StatusLogger Unable to load plugin class name org.abc.logging.AppAuditor 
> with key org.abc.logging.appauditor
>  
> It is trying to load the custom appender class as a plugin using the fully 
> qualified class name in lower case. It is unable to locate the class. The 
> system property log4j.plugin.packages was added to specify the package name 
> where the custom appender class is located.
>  
> Environment information:
> The log4j.properties file from log 4j 1.x has these entries for this custome 
> appender:
> log4j.logger.AppAuditing = _AUDIT_LOG
> log4j.appender._AUDIT_LOG=org.abc.logging.AppAuditor
>  
> The custom appender class org.abc.logging.AppAuditor extends from 
> AppenderSkeleton and implements the custom append method.
>  
> The client class using the custom appender:
> Logger log = Logger.getLogger("AppAuditing");
> log.info(message);
>  
> No other changes were made to log4j.properties used with log4j 1.x and all 
> steps were completed for log4j 1.x to log4j2 bridge migration. All other 
> logging works as expected with the bridge except the custom appender. This 
> custom appender AppAuditor also works without any issues in log4j 1.x. 



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

Reply via email to