Thorbjoern Ravn Andersen wrote:
Ceki Gulcu skrev:

See http://slf4j.org/faq.html#declared_static
The official stance is that there is no official stance. :-)
If I understand the link correctly the primary reason for recommending "not static" is to allow repository selectors to work with logback?

Hmm, I would not word it like that. Static loggers are an issue only for shared libraries which in practice are not such a big deal.

Do you have benchmark figures already for the overhead of creating a logger for each object?

You surely know the answer to that. Hint: what is the difference between static fields and instance fields referencing the very same object, in this case the same logger?

Am I right in assuming that the logback mechanism for looking up loggers is faster than in log4j? There must be a reason for the original recommandation :)

The reason for the original recommendation was mainly related to serialization which SLF4J did not support in earlier versions. Current SLF4J version support logger serialization so having loggers as a instance variables is no longer a problem.

Performance between static and instance loggers comes into play if you instantiate many (as in > 100'000) instances of the same class.

HTH,

--
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch
_______________________________________________
dev mailing list
dev@slf4j.org
http://www.slf4j.org/mailman/listinfo/dev

Reply via email to