tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Spiegs <>
Subject Re: Serializable Logging implementation
Date Fri, 17 Sep 2004 01:31:09 GMT
Ok, in a nutshell - using a private static logger in each model object 
will not be serialized across the cluster. Use the following 3 lines of 
code you provided and I won't have any problems with the log4j log 
instance not being serializable, because it never will be. Right? (I'm 
not familiar with how the Classloader handles static variables in a 
clustered environment)


-------- Original Message ------
Ditch the super class philosphy. And copy the following 3 lines of code:
import ... LogFactory;
import ... Log;
private static log = LogFactory.get...(My.class);

You don't want to use the super class philophy because debugging the 
inheritance chain becomes impossible. For example:

With a log variable at the Super class level inherited by the sub 
classes, it is IMPOSSIBLE to debug SubClass or SubSubClass. (As well as 
SuperClass) For example - I might want trace turned on for the super 
class and warn on for the rest of the classes in the hierarchy. 
Inheritance kills any chance of fine grained control of log output.

If it's static - it can't be transient. And all the instances share all 
the same log instance at the Classloader level so it is never serialized.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message