Hi, All! Is there a correct way to use Log4j logger with Common ClassLoader, not with Web-App based ClassLoader, i.e. use only one log4j.jar for all deployed web-apps? When i'm drop a log4j.jar in commons lib directory, log4j get a first loj4j.properties for any application and use only it. All other loj4j.properties (of other applications) are ignored. Is there way to say log4j to return separate log factory for every application with their properties?
+1
A:
Not in the way I think you mean, because each webapp's loggers should be completely independent of loggers in other webapps. Because logging repositories are singletons, this can only be done if they are handled by separate Classloaders, i.e. the webapp class loaders.
Also note that in general (though it may not be the case for you), different webapps have different lifecycles, which means that Tomcat may have to support webapp A using one version of log4j at the same time as webapp B, which uses a different version of log4j.
Vinay Sajip
2009-10-05 15:08:46
Yes, i'm full agree except one thing. I'm host about 60 webapps on one tomcat instance, and when every webapp load separate log4j instance - i'm get problem with PermGen space. Server has only 512Mb of memory :(
Alexey Sviridov
2009-10-05 16:22:01