You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Mansour <ma...@ownmail.net> on 2006/09/12 09:01:47 UTC

Logger.getRootLogger() or Logger.getLogger(this.getClass())

Hi there:
I am still new to logging with java. In my project I am using log4j in 
each class to trace the excution. However, at some points I'n getting 
the logs twice.
I 'll explain what I did. I am using somehting like this in all the 
classes :

Logger logger=Logger.getLogger(this.getClass());
BasicConfigurator.configure();
logger.setLevel(Level.ALL);
//some code ......
logger.info("myMessage");
//more code ....

when, a method is executed, it logs the message at least 2 times !!!
what's is going on?? by the way, I dont understand the herirachy in the 
log4j. I mean what's the difference between Logger.getRootLogger() and 
Logger.getLogger(this.getClass()) ??





---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org