Hello,

I am working on refactoring an existing application with a proprietary
logging framework.  We are integrating with Log4j and need to understand
performance/scalability as well as any best practices surrounding the
use of LogManager.getLogger(String).  Since this is a legacy system, our
plan is to lookup the Log4j Logger on every log request through
LogManager.getLogger(String).  So, the logging paradigm throughout the
entire application would be:

LogManager.getLogger("com.myclass").info("My log message 1");
...
LogManager.getLogger("com.myclass").info("My log message 2");
...
LogManager.getLogger("com.myclass").info("My log message 3");


Versus:


Final static Logger logger = Logger.getLogger("com.myclass");
...
logger.info("My log message 1");
logger.info("My log message 2");
logger.info("My log message 3");


1. Is it okay to use LogManager in this manner?
2. Are there any performance issues with this approach?
3. Are there any scalability concerns with this approach?
4. Will reloading the log4j.xml configuration work with this approach?
5. Instead of using the LogManager, does it make sense to use a static
ConcurrentHashMap to store ("logger name",Logger) key value pairs and
perform a local Logger lookup on every log request?
6. What would you recommend?

Any help would be appreciated.  Thank you.

Faheem Zakaria
Software Engineer





Reply via email to