A logger is should be thread-safe and can be used from multiple threads. You do not need to request a logger for each thread. If you do, you will just get multiple references to the same logger object.

The things you cannot do (without using socket listener) is to write have two appenders write to the same file or have two instances of log4cxx write to the same file.


On Dec 6, 2004, at 11:44 AM, Jeff Lynn wrote:

Hi,

Is is safe to log to the same log file from multiple worker threads with each thread calling the following to get a new logger instance:

LoggerPtr logger = Logger::getLogger("Test1");

whereas the main thread configured the logger as:

PropertyConfigurator::configure("log4cxx.properties");

I understand I can use the socket listener for multi-processes and multi-server environment but just wonder if it is safe if my app only runs in a single server with multiple worker threads.

Thanks!



Reply via email to