[hibernate-dev] static loggers

Hardy Ferentschik hibernate at ferentschik.de
Thu Oct 16 06:17:56 EDT 2008


Hi there,

I just wanted to get some opinion on logger creation.

I introduced a LoggerFactory class into Hibernate Search which allows the  
creation of Logger instances without having to specify the class. The idea  
behind this it coming from this article -  
http://www.javaspecialists.co.za/archive/newsletter.do?issue=137.

However, as Sanne pointed out to me, to use this pattern efficiently one  
has to declare the loggers as static. In fact I am so used to this idiom  
that I even dit not notice that in Search the loggers are declared as  
instance variables.

After looking around a little I found these articles:

* http://www.slf4j.org/faq.html#declaration_pattern
* http://wiki.apache.org/jakarta-commons/Logging/StaticLog

Seems there are pro and cons for both approaches. The biggest drawback of  
the static approach being the case where the jar is deployed as shared  
library which can screw up the log output of the using applications (even  
thought there seems to be ways around this).

Now, Hibernate Core seems to use static loggers. Does this mean we are not  
concered about the potential drawbacks of this approach?
Should we aim for a consistent usage pattern, even across the different  
Hibernate projects? Or do we maybe already have such guidelines?

--Hardy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: LoggerFactory.java
Type: application/octet-stream
Size: 1271 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/hibernate-dev/attachments/20081016/a52d2148/attachment.obj 


More information about the hibernate-dev mailing list