[
https://issues.apache.org/jira/browse/LOG4J2-3519?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17543722#comment-17543722
]
XIAOMING ZHAO edited comment on LOG4J2-3519 at 5/30/22 1:30 AM:
----------------------------------------------------------------
[~pkarwasz] and @ Apache Log4j2 team:
I set log4j2.loggerConextStackTraceOnStart to true and log4j.debug=true.
>From the felix.log, I can see the following:
there are a lot of log similar to the following:
" 464 DEBUG StatusLogger Bundle org.apache.ws.xmlschema.core has no context
(state=INSTALLED), skipping loading provider"
...
then saw it scanning some bundles like the first two of the following bundles,
but it doesn't include the jar file which include my custom layout plugin. then
I saw the stack trace, looks like on line 970, 971, it show the invoker, since
this invoker is not belong to our department, if this is the problem, I need to
contact with them. But would you please share your analysis from the following
log?
920 TRACE StatusLogger Scanning bundle
[com.mycompany.as.service.bundleinstaller.impl, id=%d] for plugins.
921 DEBUG StatusLogger Took 0.002526 seconds to load 0 plugins from
com.mycompany.as.service.bundleinstaller.impl [1]
922 TRACE StatusLogger Scanning bundle [com.mycompany.tpapps.sps-common,
id=%d] for plugins.
923 DEBUG StatusLogger Took 0.000103 seconds to load 0 plugins from
com.mycompany.tpapps.sps-common [54]
924 TRACE StatusLogger Scanning bundle [org.apache.logging.log4j.api,
id=%d] for plugins.
925 DEBUG StatusLogger Took 0.000028 seconds to load 0 plugins from
org.apache.logging.log4j.api [224]
926 TRACE StatusLogger Scanning bundle
[org.apache.aries.spifly.dynamic.bundle, id=%d] for plugins.
927 DEBUG StatusLogger Took 0.000043 seconds to load 0 plugins from
org.apache.aries.spifly.dynamic.bundle [369]
928 DEBUG StatusLogger Loaded Provider Provider[priority=10,
class=org.apache.logging.log4j.core.impl.Log4jContextFactory,
classLoader=null(not reachable)]
929 TRACE StatusLogger Scanning bundle [org.apache.logging.log4j.core,
id=%d] for plugins.
930 DEBUG StatusLogger Took 0.068493 seconds to load 222 plugins from
org.apache.logging.log4j.core [327]
931 DEBUG StatusLogger Loaded Provider Provider[priority=10,
class=org.apache.logging.log4j.core.impl.Log4jContextFactory,
classLoader=null(not reachable)]
932 TRACE StatusLogger Scanning bundle [org.apache.cxf.cxf-core, id=%d] for
plugins.
933 DEBUG StatusLogger Took 0.000090 seconds to load 0 plugins from
org.apache.cxf.cxf-core [56]
934 DEBUG StatusLogger Using ShutdownCallbackRegistry class
org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry
935 TRACE StatusLogger Log4jLoggerFactory.getContext() found anchor class
org.ops4j.pax.url.commons.handler.HandlerActivator
936 DEBUG StatusLogger Not in a ServletContext environment, thus not
loading WebLookup plugin.
937 DEBUG StatusLogger AsyncLogger.ThreadNameStrategy=UNCACHED (user
specified null, default is UNCACHED)
938 TRACE StatusLogger Using default SystemClock for timestamps.
939 DEBUG StatusLogger org.apache.logging.log4j.core.util.SystemClock does
not support precise timestamps.
940 DEBUG StatusLogger Not in a ServletContext environment, thus not
loading WebLookup plugin.
941 DEBUG StatusLogger Took 0.001434 seconds to load 222 plugins from
org.apache.logging.log4j.core [327]
942 DEBUG StatusLogger PluginManager 'Converter' found 45 plugins
943 DEBUG StatusLogger Starting OutputStreamManager SYSTEM_OUT.false.false-1
944 DEBUG StatusLogger Starting
LoggerContext[name=org.ops4j.pax.url.commons,
org.apache.logging.log4j.core.LoggerContext@2b656ab0]...
945 DEBUG StatusLogger Stack trace to locate invoker
946 DEBUG StatusLogger Initializing Thread Context Data Service Providers
947
948 DEBUG StatusLogger Thread Context Data Service Provider initialization
complete
949 java.lang.Exception: Not a real error, showing stack trace to locate
invoker
950 at
org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:263)
951 at
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:155)
952 at
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:47)
953 at
org.apache.logging.log4j.LogManager.getContext(LogManager.java:196)
954 at
org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:137)
955 at
org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:55)
956 at
org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:47)
957 at
org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:33)
958 at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:363)
959 at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388)
960 at
org.ops4j.pax.url.commons.handler.HandlerActivator.<clinit>(HandlerActivator.java:52)
961 at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
962 at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
963 at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
964 at
java.lang.reflect.Constructor.newInstance(Constructor.java:423)
965 at java.lang.Class.newInstance(Class.java:442)
966 at
org.apache.felix.framework.Felix.createBundleActivator(Felix.java:4780)
967 at
org.apache.felix.framework.Felix.activateBundle(Felix.java:2410)
968 at org.apache.felix.framework.Felix.startBundle(Felix.java:2335)
969 at
org.apache.felix.framework.BundleImpl.start(BundleImpl.java:1006)
970 at
com.mycompany.as.service.bundleinstaller.impl.BundleInstallerImpl$DeployedBundle.start(BundleInstallerImpl.java:935)
971 at
com.mycompany.as.service.bundleinstaller.impl.BundleInstallerImpl.startBundles(BundleInstallerImpl.java:624)
972 at
com.mycompany.as.service.bundleinstaller.impl.BundleInstallerImpl.finishInitialisation(BundleInstallerImpl.java:260)
973 at
com.mycompany.as.service.bundleinstaller.impl.BundleInstallerImpl.frameworkEvent(BundleInstallerImpl.java:244)
974 at
org.apache.felix.framework.EventDispatcher.invokeFrameworkListenerCallback(EventDispatcher.java:881)
975 at
org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:830)
976 at
org.apache.felix.framework.EventDispatcher.run(EventDispatcher.java:1147)
977 at
org.apache.felix.framework.EventDispatcher.access$000(EventDispatcher.java:54)
978 at
org.apache.felix.framework.EventDispatcher$1.run(EventDispatcher.java:102)
979 at java.lang.Thread.run(Thread.java:750)
980 DEBUG StatusLogger Reconfiguration started for
context[name=org.ops4j.pax.url.commons] at URI null
(org.apache.logging.log4j.core.LoggerContext@2b656ab0) with optional
ClassLoader: null
981 DEBUG StatusLogger Not in a ServletContext environment, thus not
loading WebLookup plugin.
982 DEBUG StatusLogger PluginManager 'ConfigurationFactory' found 4 plugins
983 DEBUG StatusLogger Not in a ServletContext environment, thus not
loading WebLookup plugin.
984 DEBUG StatusLogger Not in a ServletContext environment, thus not
loading WebLookup plugin.
985 DEBUG StatusLogger Not in a ServletContext environment, thus not
loading WebLookup plugin.
986 DEBUG StatusLogger Not in a ServletContext environment, thus not
loading WebLookup plugin.
was (Author: JIRAUSER290069):
[~pkarwasz] and @ Apache Log4j2 team:
I set log4j2.loggerConextStackTraceOnStart to true and log4j.debug=true.
>From the felix.log, I can see the following:
there are a lot of log similar to the following:
" 464 DEBUG StatusLogger Bundle org.apache.ws.xmlschema.core has no context
(state=INSTALLED), skipping loading provider"
...
then saw it scanning some bundles like the first two of the following bundles,
but it doesn't include the jar file which include my custom layout plugin. then
I saw the stack trace, looks like on line 970, 971, it show the invoker, since
this invoker is not belong to our department, if this is the problem, I need to
contact with them. But would you please share your analysis from the following
log?
920 TRACE StatusLogger Scanning bundle
[com.mycompany.as.service.bundleinstaller.impl, id=%d] for plugins.
921 DEBUG StatusLogger Took 0.002526 seconds to load 0 plugins from
com.alcatel.as.service.bundleinstaller.impl [1]
922 TRACE StatusLogger Scanning bundle [com.mycompany.tpapps.sps-common,
id=%d] for plugins.
923 DEBUG StatusLogger Took 0.000103 seconds to load 0 plugins from
com.nokia.tpapps.sps-common [54]
924 TRACE StatusLogger Scanning bundle [org.apache.logging.log4j.api,
id=%d] for plugins.
925 DEBUG StatusLogger Took 0.000028 seconds to load 0 plugins from
org.apache.logging.log4j.api [224]
926 TRACE StatusLogger Scanning bundle
[org.apache.aries.spifly.dynamic.bundle, id=%d] for plugins.
927 DEBUG StatusLogger Took 0.000043 seconds to load 0 plugins from
org.apache.aries.spifly.dynamic.bundle [369]
928 DEBUG StatusLogger Loaded Provider Provider[priority=10,
class=org.apache.logging.log4j.core.impl.Log4jContextFactory,
classLoader=null(not reachable)]
929 TRACE StatusLogger Scanning bundle [org.apache.logging.log4j.core,
id=%d] for plugins.
930 DEBUG StatusLogger Took 0.068493 seconds to load 222 plugins from
org.apache.logging.log4j.core [327]
931 DEBUG StatusLogger Loaded Provider Provider[priority=10,
class=org.apache.logging.log4j.core.impl.Log4jContextFactory,
classLoader=null(not reachable)]
932 TRACE StatusLogger Scanning bundle [org.apache.cxf.cxf-core, id=%d] for
plugins.
933 DEBUG StatusLogger Took 0.000090 seconds to load 0 plugins from
org.apache.cxf.cxf-core [56]
934 DEBUG StatusLogger Using ShutdownCallbackRegistry class
org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry
935 TRACE StatusLogger Log4jLoggerFactory.getContext() found anchor class
org.ops4j.pax.url.commons.handler.HandlerActivator
936 DEBUG StatusLogger Not in a ServletContext environment, thus not
loading WebLookup plugin.
937 DEBUG StatusLogger AsyncLogger.ThreadNameStrategy=UNCACHED (user
specified null, default is UNCACHED)
938 TRACE StatusLogger Using default SystemClock for timestamps.
939 DEBUG StatusLogger org.apache.logging.log4j.core.util.SystemClock does
not support precise timestamps.
940 DEBUG StatusLogger Not in a ServletContext environment, thus not
loading WebLookup plugin.
941 DEBUG StatusLogger Took 0.001434 seconds to load 222 plugins from
org.apache.logging.log4j.core [327]
942 DEBUG StatusLogger PluginManager 'Converter' found 45 plugins
943 DEBUG StatusLogger Starting OutputStreamManager SYSTEM_OUT.false.false-1
944 DEBUG StatusLogger Starting
LoggerContext[name=org.ops4j.pax.url.commons,
org.apache.logging.log4j.core.LoggerContext@2b656ab0]...
945 DEBUG StatusLogger Stack trace to locate invoker
946 DEBUG StatusLogger Initializing Thread Context Data Service Providers
947
948 DEBUG StatusLogger Thread Context Data Service Provider initialization
complete
949 java.lang.Exception: Not a real error, showing stack trace to locate
invoker
950 at
org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:263)
951 at
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:155)
952 at
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:47)
953 at
org.apache.logging.log4j.LogManager.getContext(LogManager.java:196)
954 at
org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:137)
955 at
org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:55)
956 at
org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:47)
957 at
org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:33)
958 at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:363)
959 at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388)
960 at
org.ops4j.pax.url.commons.handler.HandlerActivator.<clinit>(HandlerActivator.java:52)
961 at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
962 at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
963 at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
964 at
java.lang.reflect.Constructor.newInstance(Constructor.java:423)
965 at java.lang.Class.newInstance(Class.java:442)
966 at
org.apache.felix.framework.Felix.createBundleActivator(Felix.java:4780)
967 at
org.apache.felix.framework.Felix.activateBundle(Felix.java:2410)
968 at org.apache.felix.framework.Felix.startBundle(Felix.java:2335)
969 at
org.apache.felix.framework.BundleImpl.start(BundleImpl.java:1006)
970 at
com.mycompany.as.service.bundleinstaller.impl.BundleInstallerImpl$DeployedBundle.start(BundleInstallerImpl.java:935)
971 at
com.mycompany.as.service.bundleinstaller.impl.BundleInstallerImpl.startBundles(BundleInstallerImpl.java:624)
972 at
com.mycompany.as.service.bundleinstaller.impl.BundleInstallerImpl.finishInitialisation(BundleInstallerImpl.java:260)
973 at
com.mycompany.as.service.bundleinstaller.impl.BundleInstallerImpl.frameworkEvent(BundleInstallerImpl.java:244)
974 at
org.apache.felix.framework.EventDispatcher.invokeFrameworkListenerCallback(EventDispatcher.java:881)
975 at
org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:830)
976 at
org.apache.felix.framework.EventDispatcher.run(EventDispatcher.java:1147)
977 at
org.apache.felix.framework.EventDispatcher.access$000(EventDispatcher.java:54)
978 at
org.apache.felix.framework.EventDispatcher$1.run(EventDispatcher.java:102)
979 at java.lang.Thread.run(Thread.java:750)
980 DEBUG StatusLogger Reconfiguration started for
context[name=org.ops4j.pax.url.commons] at URI null
(org.apache.logging.log4j.core.LoggerContext@2b656ab0) with optional
ClassLoader: null
981 DEBUG StatusLogger Not in a ServletContext environment, thus not
loading WebLookup plugin.
982 DEBUG StatusLogger PluginManager 'ConfigurationFactory' found 4 plugins
983 DEBUG StatusLogger Not in a ServletContext environment, thus not
loading WebLookup plugin.
984 DEBUG StatusLogger Not in a ServletContext environment, thus not
loading WebLookup plugin.
985 DEBUG StatusLogger Not in a ServletContext environment, thus not
loading WebLookup plugin.
986 DEBUG StatusLogger Not in a ServletContext environment, thus not
loading WebLookup plugin.
> Log4j2 failed to load custom plugin
> ------------------------------------
>
> Key: LOG4J2-3519
> URL: https://issues.apache.org/jira/browse/LOG4J2-3519
> Project: Log4j 2
> Issue Type: Bug
> Components: Plugins
> Affects Versions: 2.17.1
> Reporter: XIAOMING ZHAO
> Priority: Major
>
> We got some issue to load the custom plugin.
> we add annotation Plugin like the following:
> @Plugin(name = "UnifiedLoggingFormat", category = Node.CATEGORY,
> elementType = Layout.ELEMENT_TYPE, printObject = true)
> public class UnifiedLoggingFormat extends AbstractStringLayout
> then add the annotationProcessor in build.gradle
> annotationProcessor( 'org.apache.logging.log4j:log4j-core:2.17.1')
>
> after the build, we can see the
> META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat in
> the class jar file.
> > jar tvf *appender*.jar
> 0 Tue May 24 14:18:40 EDT 2022 META-INF/
> 1077 Tue May 24 14:18:40 EDT 2022 META-INF/MANIFEST.MF
> 0 Tue May 24 14:18:40 EDT 2022 META-INF/org/
> 0 Tue May 24 14:18:40 EDT 2022 META-INF/org/apache/
> 0 Tue May 24 14:18:40 EDT 2022 META-INF/org/apache/logging/
> 0 Tue May 24 14:18:40 EDT 2022 META-INF/org/apache/logging/log4j/
> 0 Tue May 24 14:18:40 EDT 2022 META-INF/org/apache/logging/log4j/core/
> 0 Tue May 24 14:18:40 EDT 2022
> META-INF/org/apache/logging/log4j/core/config/
> 0 Tue May 24 14:18:40 EDT 2022
> META-INF/org/apache/logging/log4j/core/config/plugins/
> 236 Tue May 24 14:18:40 EDT 2022
> META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat
>
> then in log42j.xml, we added the package of this custom plugin class.
> <Configuration status="trace" monitorInterval="30"
> packages="com.server.logging.log4jappenders, com.common.utils">
>
> but we still got the problem
> FelixDispatchQueue DEBUG Took 0.003516 seconds to load 0 plugins from package
> com.server.logging.log4jappenders
> FelixDispatchQueue DEBUG Took 0.000117 seconds to load 0 plugins from package
> com.common.utils
>
> Would you please help out?
--
This message was sent by Atlassian Jira
(v8.20.7#820007)