[prev in list] [next in list] [prev in thread] [next in thread] 

List:       log4j-dev
Subject:    Long startup time - searching through all jars?
From:       Wolfgang Hoschek <whoschek () lbl ! gov>
Date:       2003-10-25 0:52:57
[Download RAW message or body]

Folks,

In a specific setting I am seeing poor startup time using log4-1.2.8,
and am asking for advice. I have a command line java client with a 
simple log4j.properties file, properly configured via 
-Dlog4j.configuration, and on a fast 2 GHz linux box with jdk-1.4.2_02, 
it starts up quickly in 0.3 secs with and without log4j, if there is 
nothing else on the classpath. So long, fine.

However, the reality here is that there are also 20 other sizable jar 
files on the classpath (log4j.jar is first on the classpath), then it 
takes 0.3 secs to startup without log4j, and 1.5 secs with log4j.

My best guess is that this is because log4j might search all jars on the 
classpath for something it does not need (since -Dlog4j.configuration is 
properly set to a file:///path/to/log4j.properties URL that should 
suffice), or to find something that is not there (some strange class 
like a VisualAge class to check for environment or version details or 
such). I patched LogManager.java with a few more LogLog.debug messages 
to confirm that my -Dlog4j.configuration URL works find and 
Loader.getResource is not called in the static initializer of 
LogManager, but still guess that somewhere deep inside all jars are 
searched for some resource.

Could log4j be modified such that it does not search the classpath only 
to find nothing there? As a sample use case, try imagining a small unix 
like command line program that prints its "help on usage" or "--version" 
blurb only after 1.5 secs even on a high end box? Not terribly 
convincing...

Here is simple helloworld to reproduce the behaviour. Just dump some 20 
jar files (like axis, xerces, jaxrpc, jaxb, ...) into the classpath 
(after log4j) and see for yourself.

public class Test5 {
     private static final org.apache.log4j.Logger log = 
org.apache.log4j.Logger.getLogger(Test5.class);

     public static void main(String[] args) {
         System.out.println("hello world");
     }
}

Not sure if commons-logging does similar things. In other words, if 
log4j could be fixed, would commons-logging on top of log4j defeat the 
purpose?

For those who care, thanks for any advice.
Wolfgang.


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic