Since the logging implementations cache the loggers, I let them broker instances...
-Kevin
Kevin Ross wrote:
As I mentioned in my previous message, this is a poor way to obtain a logger, especially if you have deep inheritance heirarchies. Since I'm a big fan of OO programming, and my heirarchies are especially deep, I find the static way of obtaining a logger invalid.
Try this:
public class AbstractLoggable{
private static transient Logger logger;
protected Logger getLogger(){
if( logger == null ){
logger = Logger.getLogger(getClass());
}
return logger;
}
}
whallah! efficient OO programming with an accessor for subclasses and the proper class name to go with it!
-Kevin Ross
Vladimir R. Bossicard wrote:
Logger.getLogger(getClass()) at least, whether or not you use the string name is of no consequence.have you ever tried to call a non-static method within a static reference?if you get this working: private static Log log = LogFactory.getLog(getClass()); I give you a high-five. -Vladimir -- Vladimir R. Bossicard www.bossicard.com
