[slf4j-user] Is it not safe to store the Logger instance into a static field?

Ruimo Uno ruimo.uno at gmail.com
Fri Mar 3 10:28:10 CET 2006


2006/3/3, Boris Unckel <boris.unckel.mlg at gmx.net>:
> > The example code shown here http://www.slf4j.org/manual.html stores
> > the Logger instance into a * non-static field *. Is it still harmful to
> > store
> > the Logger instance into a static field as well as JCL?
> I think yes. If you sharing a class via a shared/common classloader
> (Tomcat), linked/non-hierarchical classloaders (JBoss, WAS) you will get
> problems with static logging fields.
> This has nothing to do with statically linked/dynamically linked logging
> wrapper but with the TCCL.

Thank you for your answer. BTW, I'm not fully understand the cause of
this problem (just avoid it). Is there any document that describes the cause
of this problem? I've searched mailing list archives of JCL and SLF4J and
in vain.

The following document is really helpful for me to understand the class
loader issues. Unfortunately, it does not talk about the static field problem,
though.

http://www.qos.ch/logging/classloader.jsp

--
Ruimo Uno
(Shisei Hanai)



More information about the slf4j-user mailing list