On Oct 22, 2006, at 4:49 AM, Cohen Oren (ICS) wrote:
Thanks Curt ! Regarding item 3 (below) : I meant that I will not use "append" for adding a Logging Event to the thread's queue, but rather a regular "add()" command. Each thread will put its events on its own logging queue by using "add()" method (like adding a regular object to a linked list). The threads will NOT use log4j. However, the new dispatcher I'll write, will go over these queues (round-robin), get the logging events from it, and will use the log4j mechanism and its "append()" method in order to add them to the FileAppender. So, it seems as if no block will be done. Correct ?
By the time that log4j has processed an logging request to the point that an Appender is called with a LoggingEvent, log4j will have have an synchronization lock and will block any other threads until the appender completes its append action (which in your case would be the add to a thread-local collection). In either your suggested approach or using the AsyncAppender with blocking=false, there is still the chance for a thread to be blocked, but the duration of the block is substantially reduced since it is only the time to add to a collection, not the time it takes for the File IO to complete. Since at the point your appender would get a call, you are guaranteed to be synchronized, using thread-local collections would not have a benefit.
If you have a case of the logging requests being generated in bursts faster than the underlying appender can handle, you need some mechanism to avoid exhausting all your memory holding logging events for later processing. The new AsyncAppender provides two mechanisms to handle this case, the old-style blocking behavior where the calling thread is blocked until the queue dropped below the specified maximum size (which can cause the calling application to stall until the queue is drained) and the newly introduced non-blocking style where overflow logging events are counted and summarized. You haven't described how you would address that issue in your appender.
Again, I would recommend that you look at the log4j 1.2.14 AsyncAppender with the blocking=false option as it should address your major concerns.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
