[
https://issues.apache.org/jira/browse/LOG4J2-393?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13764397#comment-13764397
]
Philipp Hedwig commented on LOG4J2-393:
---------------------------------------
We are using Oracle JRE/JDK 1.7.0u09 on Win32. There are no libs in the
endorsed path and we haven't intentionally overridden any classes of xerces or
the JRE. We have a pretty old xerces.jar in our classpath, though.
After removing our old xerces.jar from the classpath, further debugging showed,
that the xalan.jar we are using defines a service
{{META-INF/services/javax.xml.parsers.DocumentBuilderFactory}} linked to the
_org.apache.xerces.jaxp.DocumentBuilderFactoryImpl_ implementation of
{{DocumentBuilderFactoryImpl}}. After removing the xerces.jar, the
implementation can't be found. If we remove the service definition from the
xalan.jar, then the fallback implementation from the JRE is used. But I don't
know if this leads to problems with xalan itself ...
Changing/removing this many libs can cause many problems and finding those by
testing our application would be problematic, too. It's a high risk of crashes
in the production environment.
Updating xalan to the newest version or removing the jar helps with the
{{DocumentBuilderFactory}}-problem, but I can't estimate the consequences. So a
fallback option for extremely old xerces-versions would be very appreciated.
> Low initialization performance when using Log4J with jar packages
> -----------------------------------------------------------------
>
> Key: LOG4J2-393
> URL: https://issues.apache.org/jira/browse/LOG4J2-393
> Project: Log4j 2
> Issue Type: Bug
> Components: Configurators, Core
> Affects Versions: 2.0-beta8
> Reporter: Philipp Hedwig
> Labels: performance
> Fix For: 2.0-beta9
>
>
> We discovered a huge performance difference when initializing Log4J with
> deployed jar packages compared to using it directly with normal class files.
> As it seems,
> _org.apache.logging.log4j.core.config.plugins.ResolverUtil#loadImplementationsInJar_
> is way slower than its counterpart
> _org.apache.logging.log4j.core.config.plugins.ResolverUtil#loadImplementationsInDirectory_
> and since this method gets called a few hundred times at initialization in
> this project, initialization of Log4J took more than 2 minutes with jar
> packages, compared to a few seconds with class files.
> The performance issue was already mentioned in
> [LOG4J2-184|https://issues.apache.org/jira/browse/LOG4J2-184], only without
> the jar problem.
> The solution to [LOG4J2-175|https://issues.apache.org/jira/browse/LOG4J2-175]
> might cause this, but we are unsure why the methods exactly get called this
> often.
> I just can tell that
> _org.apache.logging.log4j.core.config.plugins.PluginManager#collectPlugins()_
> gets called VERY often via
> _org.apache.logging.log4j.core.config.BaseConfiguration#getPluginManager_,
> which gets called by
> _org.apache.logging.log4j.core.config.XMLConfiguration#constructHierarchy_
> And _collectPlugins()_ is remapped to _collectPlugins(boolean preLoad, final
> String pkgs)_ with _collectPlugins(true, null);_. I'm unsure what this
> preLoad is for, since it gets overridden with false and apparently no kind of
> caching is used. In this method, _resolver.findInPackage(test, pkg);_ takes a
> whole lot of time searching within the jars, as described in the beginning.
> The only way to work around this was for us to extract the custom appender in
> a sperate ant build target, and with this in a seperate jar, to minimize the
> size of the jar, reducing the search time.
> Can you cache things and maybe reduce the calls to _collectPlugins()_? I
> don't see the probability of changing plugins during initialization as
> described in LOG4J2-175 or the comment in
> _org.apache.logging.log4j.core.config.BaseConfiguration#getPluginManager_.
> Introducing a variable for the plugin manager within the for loop in
> _org.apache.logging.log4j.core.config.XMLConfiguration#constructHierarchy_
> might be a good idea!
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]