tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Remy Maucherat <r...@apache.org>
Subject Re: Web apps vs. Logging vs. Tomcat
Date Sat, 19 Mar 2005 18:30:59 GMT
Jess Holle wrote:
> Remy Maucherat wrote:
> What's unexpected here is as you say that these loggers are static -- or 
> in any event not per-web-app.  Otherwise, this behavior would be fine 
> and good!

Yes, I forgot about Jasper when I added the container loggers in 5.5 :(
At first when we added commons-logging support, we added static loggers 
everywhere, since it was very easy this way.

Example from the main JSP servlet class:
private static Log log = LogFactory.getLog(JspServlet.class);

So since Jasper is in the common classloader, the class definition will 
be loaded only once, and the loggers used by Jasper will be associated 
with the first webapp which is loaded. It's a bit random, since some 
classes (ex: the compiler) may be loaded a bit later by other webapps.
-> configuration nightmare

I also added fixes recently so that loggers are not accessed too early, 
which was a similar issue (some loggers would be have be improperly 
associated with the container classloader). There's lots of tweaking 
needed with logging overall, it's sort of to be expected.

Here, I suppose modifying all the loggers to be like this:
private Log log = LogFactory.getLog(JspServlet.class);
would fix the issue without further problems.

>> Another completely different strategy for acquiring loggers is to use 
>> the CL which loaded the class (ie, to use straight delegation). 
>> There's the problem that it could cause classcast exceptions, however, 
>> and it's more annoying to configure.
>>
>> Both solutions behave differently, but they have their own merits. I 
>> happen to prefer the context classloader oriented one in a J2EE 
>> environment (so it was used for the java.util.logging implementation I 
>> added recently based on some user submitted code that I heavily 
>> modfied - see http://issues.apache.org/bugzilla/show_bug.cgi?id=33143).
> 
> Yes, I now have both approaches coded and as you say both have their 
> merits.  If the instances wherein Tomcat loggers configured/obtained 
> from one web app are used across web apps are eliminated in Tomcat 
> 5.5.x, then I could happily use the JNDI/J2EE approach and all Tomcat's 
> own loggers for each web app would use that web app's configuration.  
> Otherwise I really have to go with the straight delegation approach to 
> prevent cross-web-app logger effects.

It's not the official J2EE way (there's no official J2EE way, as the 
default java.util.logging implementation is one global namespace 
unsuitable for containers), but it's similar to JNDI handling.

Rémy

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


Mime
View raw message