Posted By:
Oren_Co
Posted On:
Tuesday, October 17, 2006 06:18 AM
Hi I need the best log4j configuration for - many threads that log events to the same file concurrently I work on a multithreaded environment (between 10-20 threads). I want all the threads to log their events to the same log file. Currently, there are 3 Loggers in the system - all of them are by default sons of the RootLogger. I are running some load tests and facing some performance difficulties. I tried 2 major setups in my log4j.xml : First setup: RollingFileAppender - attached to the RootLogger. The performance is bad because log4j locks (synchronize) the Category/Logger until it finishes appending into it. Most of the threads are
More>>
Hi
I need the best log4j configuration for - many threads that log events to the same file concurrently
I work on a multithreaded environment (between 10-20 threads).
I want all the threads to log their events to the same log file.
Currently, there are 3 Loggers in the system - all of them are by default sons of the RootLogger.
I are running some load tests and facing some performance difficulties. I tried 2 major setups in my log4j.xml :
First setup:
RollingFileAppender - attached to the RootLogger.
The performance is bad because log4j locks (synchronize) the Category/Logger until it finishes appending into it.
Most of the threads are waiting until the lock on the RoorLogger is finished (because it has the appender).
Second setup:
AsyncAppender - attached to the RootLogger.
RollingFileAppender - attached to the AsyncAppender .
The buffer of the AsyncAppender is synchronized,
and as mentioned before - the loggers are also synchronized once they start appending the event.
Most of the threads are waiting until the lock on the RoorLogger is finished.
I took many advices from the log4j book (enlarge the buffer of AsyncAppender, use BufferedIO in the RollingFileAppender, omit locationInfo etc.)
However, I still don't have a good configuration for my very simple case (many threads that log events to the same file concurrently).
Can you help ?
<<Less