[
https://issues.apache.org/jira/browse/LOG4J2-3499?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17532377#comment-17532377
]
Xitiz Bhatia commented on LOG4J2-3499:
--------------------------------------
[~pkarwasz] Thank you for your response.
The custom appender class org.abc.logging.AppAuditor is processing the log
event message and then saving them into a database table. The appender class
extends from org.apache.log4j.AppenderSkeleton and overrides the
"append(org.apache.log4j.spi.LoggingEvent loggingEvent)" method that gets the
message using loggingEvent.getMessage() and inserts into it into database after
processing it. Unfortunately, I will not be able to share the code of the
custom appender due to licensing issues.
With log4j 1.x, the debugger stops at the debug point on append(logEvent)
however, when using the log4j bridge, the debugger doesn't come to the debug
point on append(logEvent) method in the custom appender causing me to believe
that the appender is never initialized. The only message that I found in the
server logs after adding log4j.debug system property is that it could not load
the plugin class for the key. I am not sure if it is trying to directly
initiate the appender after that.
It makes sense that the log4j bridge may not find the plugin for this custom
appender. Using your suggestions, I will try to use the native JDBC appender
for log4j2 or rewrite it as a custom log4j2 appender.
I wanted to report this in Jira in case there is a bug that someone else may
also have come across that log4j bridge may not be initializing the custom
appenders extending AppenderSkeleton when it fails to find a builder plugin for
it.
If there is any way to provide generate logging for why it is not able to
initialize the custom appender other than using the log4j.debug system
property, then please let me know.
> 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
> Assignee: Piotr Karwasz
> 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)