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

Attachment: LoggerFactory.java
Description: Binary data

_______________________________________________
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev

Reply via email to