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

Andreas Rytina commented on LOG4J2-184:
---------------------------------------

hello Ralph, hello Scott,
I added a trace statement in the first line of 
org.apache.logging.log4j.core.config.plugins.ResolverUtil.findInPackage(Test, 
String) 
The output then is:

find in package 'org.apache.logging.log4j.core'
find in package 'org.apache.logging.log4j.core'
find in package 'org.apache.logging.log4j.core'
find in package 'org.apache.logging.log4j.core'
find in package 'org.apache.logging.log4j.core'
find in package 'org.apache.logging.log4j.core'
find in package 'org.apache.logging.log4j.core'
find in package 'org.apache.logging.log4j.core'
find in package 'org.apache.logging.log4j.core'
find in package 'org.apache.logging.log4j.core'
find in package 'org.apache.logging.log4j.core'
2013-04-03 08:57:17,212 DEBUG Generated plugins in 0.120021604 seconds
2013-04-03 08:57:17,219 DEBUG Calling createLayout on class 
org.apache.logging.log4j.core.layout.PatternLayout for element PatternLayout 
with params(pattern="%m%n", Configuration(ConfigTest), null, charset="null")
find in package 'org.apache.logging.log4j.core'
find in package 'org.apache.logging.log4j.core'
2013-04-03 08:57:17,347 DEBUG Generated plugins in 0.127478777 seconds
2013-04-03 08:57:17,348 DEBUG Calling createAppender on class 
org.apache.logging.log4j.core.appender.ConsoleAppender for element Console with 
params(PatternLayout(%m%n), null, target="null", name="STDOUT", follow="null", 
suppressExceptions="null")
2013-04-03 08:57:17,349 DEBUG Jansi is not installed
2013-04-03 08:57:17,349 DEBUG Calling createAppenders on class 
org.apache.logging.log4j.core.config.plugins.AppendersPlugin for element 
appenders with params(appenders={STDOUT})
find in package 'org.apache.logging.log4j.core'
find in package 'org.apache.logging.log4j.core'
2013-04-03 08:57:17,458 DEBUG Generated plugins in 0.108297714 seconds
2013-04-03 08:57:17,459 DEBUG Calling createAppenderRef on class 
org.apache.logging.log4j.core.config.AppenderRef for element appender-ref with 
params(ref="STDOUT", level="null", null)
2013-04-03 08:57:17,460 DEBUG Calling createLogger on class 
org.apache.logging.log4j.core.config.LoggerConfig$RootLogger for element root 
with params(additivity="null", level="debug", 
appender-ref={org.apache.logging.log4j.core.config.AppenderRef@62f49ef9}, 
properties={}, Configuration(ConfigTest), null)
2013-04-03 08:57:17,461 DEBUG Calling createLoggers on class 
org.apache.logging.log4j.core.config.plugins.LoggersPlugin for element loggers 
with params(loggers={root})
log4j 2.0 initialization took 1011ms

You can see that the package 'org.apache.logging.log4j.core' is scanned several 
times. One approach to improve the performance is not to to search in core 
packages of log4j but rather to provide the core plugins in an other 
(persisted) way because the core plugins are anyway known and they don't needed 
to be searched. Searching for packages should only be needed for plugins which 
are provided by the log4j user. What do you mean?
                
> the performance for the log4j initialization needs to be improved
> -----------------------------------------------------------------
>
>                 Key: LOG4J2-184
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-184
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0-beta4
>            Reporter: Andreas Rytina
>         Attachments: Log4j2InitializationPerformanceTest.java
>
>
> The initialization of Log4j 2.0 beta4 via an InputStream takes too long. I 
> attached an small performance test which reproduces the problem. On my 
> machine (Dell Latidude E6530 with an Intel Core i7-3720QM CPU @ 2.6 GHz and 8 
> GB RAM, OS: Windows 7 64-bit) the test takes approximately one second to 
> complete. On the machine at the customer project, I'm currently working on, 
> it's even worse.
> After analyzing this, I found out that the method 
> org.apache.logging.log4j.core.config.plugins.PluginManager.collectPlugins() 
> is called way to often which consumes most time of the initialization!
> here the output with status=debug:
> 2013-04-01 18:42:37,337 DEBUG Generated plugins in 0.115481476 seconds
> 2013-04-01 18:42:37,344 DEBUG Calling createLayout on class 
> org.apache.logging.log4j.core.layout.PatternLayout for element PatternLayout 
> with params(pattern="%m%n", Configuration(ConfigTest), null, charset="null")
> 2013-04-01 18:42:37,469 DEBUG Generated plugins in 0.125255928 seconds
> 2013-04-01 18:42:37,471 DEBUG Calling createAppender on class 
> org.apache.logging.log4j.core.appender.ConsoleAppender for element Console 
> with params(PatternLayout(%m%n), null, target="null", name="STDOUT", 
> follow="null", suppressExceptions="null")
> 2013-04-01 18:42:37,471 DEBUG Jansi is not installed
> 2013-04-01 18:42:37,472 DEBUG Calling createAppenders on class 
> org.apache.logging.log4j.core.config.plugins.AppendersPlugin for element 
> appenders with params(appenders={STDOUT})
> 2013-04-01 18:42:37,580 DEBUG Generated plugins in 0.107575072 seconds
> 2013-04-01 18:42:37,581 DEBUG Calling createAppenderRef on class 
> org.apache.logging.log4j.core.config.AppenderRef for element appender-ref 
> with params(ref="STDOUT", level="null", null)
> 2013-04-01 18:42:37,582 DEBUG Calling createLogger on class 
> org.apache.logging.log4j.core.config.LoggerConfig$RootLogger for element root 
> with params(additivity="null", level="debug", 
> appender-ref={org.apache.logging.log4j.core.config.AppenderRef@39757c6f}, 
> properties={}, Configuration(ConfigTest), null)
> 2013-04-01 18:42:37,582 DEBUG Calling createLoggers on class 
> org.apache.logging.log4j.core.config.plugins.LoggersPlugin for element 
> loggers with params(loggers={root})
> log4j 2.0 initialization took 988ms

--
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]

Reply via email to