mercredi 25 février 2015

log4j - Configuring logger name



I've been using log4j for some time. One thing I've never really understood is why they recommend configuring the logger name from the class. Specifically, I wonder:



  1. What is the difference the three logger declarations?

  2. Which is better and why?

  3. Is there a method that allows copy and paste log declaration without having to type the name of the class somewhere? I'd prefer something that didn't use reflection for performance sake.


For example, consider class MyClass. Three declarations I've run across are:




  • final Logger myLogger = LogManager.getLogger(Log4Web_WebTL.class.getName());




  • final Logger myLogger = LogManager.getLogger(MyClass.class);




  • final Logger myLogger = LogManager.getLogger("MyClass");




I have read the doc, and I see references to the first and second forms on on the log4j site, but I don't understand what the advantage is.




Aucun commentaire:

Enregistrer un commentaire