Hi My scenario is that I am running a webapp consisting of JSP pages and Java classes. I have run this under WebSphere 5.x and Tomcat 4.1.x. I have overridden the Logger class in the same manner as in the Log4J example subclass/MyLogger.java. This allows per-thread logging levels to be altered at runtime. Log4J has been installed at the application server level, so that any web apps can use Log4J, as well as there being a default configuration for any default Logger created by any app. I have then configured my code to use my factory.
The problem occurs if I restart the web application through the appropriate admin console on either app server. Upon starting up my classes have static fields for their logger, using my loggers overridden getInstance method which returns a Logger object which I then cast to my class (ThreadLogger). This works the first time it is called when the app server starts up and my webapp is started for the first time. But when the webapp is restarted, on calling getInstance the logger classes in particular where it retrieves the stored Logger from its static hash table in the repository, return my previous ThreadLogger object. But when I try to cast this to my ThreadLogger, it gives me a ClassCastException. I believe this is due to the fact that when a web app is restarted a new WebAppClassLoader (of what ever type dependant upon the app server) is created. So the Logger object returned after my webapp is restart was created by the first instance of the WebAppClassLoader, but it is being checked by a second instance of the WebAppClassLoader, which no longer thinks they are the same ThreadLogger class. To work around this problem under WebSphere I installed the Log4J installation under my WebApp, and changed the modules class loader order to PARENT_LAST so that it would use the Log4J instance in my webapp not the app server. This way everything (including the logger repository) is unloaded on restarting a webapp. I tried the same approach under Tomcat, but this does not appear to work, and it is continuing to use the Log4J installed and configured at the app server level, so I am unable to restart my webapp without restarting the appserver. What I am after is either a solution to how I can have Log4J installed at the app server level, but allow me to continue using, extended Loggers on a per-webapp basis. Or a recommendation on how Log4J should be installed which differs from how I have things setup. If it turns out to be a problem with Tomcat in someway, then I will post to their mailing list. Thanks for your help Tony --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]