Am Montag, 18. Juni 2007 schrieb Grégory Joseph: > On Jun 18, 2007, at 20:12 , Oliver Lietz wrote: > > Hi Greg, > > > > have you read "Should Logger members of a class be declared as > > static?" - > > http://slf4j.org/faq.html#declared_static? Any comments?
I hadn't any problems with logging so far, but I think if we change it we should do it right. > Not before just now. I'm curious to know who "this author" is, > because he's basically recalling us what a static variable is... duh. I'm sure it's Ceki Gülcü, the author of log4j and slf4j, see http://www.qos.ch/logging/index.html He did comment MAGNOLIA-1461, "Remove commons-logging". > The point is: in webapps, you have a separate classloader (and that's > per the spec, afaik). Log4j being loaded by the webapp and not the > container (at least.. ideally...), I don't think it's a concern. Here are some relevant articles related to logging and class loading in Tomcat and Jetty (if anyone is interested in what is happening inside): http://tomcat.apache.org/tomcat-5.5-doc/logging.html http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html http://docs.codehaus.org/display/JETTY/Debugging and more on Ceki’s page mentioned above. > Besides, I'm generally against logging and in favor of short-lived > instances. I wouldn't want a fanatic logger to argue that his classes > has to have a long life (i.e as a singleton when it's unnecessary) > for the sake of avoiding retrieving a logger instance at every > instanciation (while instanciation IS cheap per se, I'm not convinced > that retrieving a logger is; that mostly depends on the underlying > logging mechanism, I guess) So if I understand you right, you share the opinion to not use a single static instance but create a new instance variable wherever we need a logger? Besides the use of instance vs. static variables there is another point, the use of isDebugEnabled() (when only a single log call is done inside the following block) and String concatenating. We can improve it by following the examples shown at "What is the fastest way of (not) logging?" - http://slf4j.org/faq.html#logging_performance. O. ---------------------------------------------------------------- for list details see http://documentation.magnolia.info/docs/en/editor/stayupdated.html ----------------------------------------------------------------
