On Oct 25, 2006, at 2:57 AM, Cohen Oren (ICS) wrote:

Thanks again Curt for your quick response.

1) The AsyncAppender buffer is a queue (FIFO), with lots of appending at
its beginning, and one Dispatcher that gets the events from the other
side.

As rewritten in log4j 1.2.14, the dispatch thread gets a snapshot of the entire pending event queue, clears the queue and then works through its local array of the events from the queue. It does not remove an event at a time from the start of the queue.


That's the reason I thought that LinkedList would be best. Since
I'm working with many threads, I set the buffer size to 200,000 and then
I reduced it to 20,000. I set it to such a big number because I didn't
want to lose too much events (I'm now in block=false). However, I guess
that if the implementation is ArrayList and my buffer is so big, then
the performance will be poor.

The bufferSize is never used to set the size of the ArrayList, it is only used to limit how large it can grow. Setting a large value for the buffer size will not immediately cost you memory, it will only cost you memory when you start needing to have that many items in the queue. Depending on how large your queue grows, you may become sluggish or you may exhaust the heap space and start getting out of memory exceptions.


If I set the buffer size too small, I will
lose many events (that will only be counted and summerized, instead of
being logged).
Do you have any recommendation for the maximum buffer size ?


The default value is 128, but that is a holdover from the old design. It is probably not a bad default, but it depends on the nature of your application. For you to hit that limit, you would have to have a bursty section that makes logging requests roughly 128 times faster than your underlying appender can handle it or your application consistently is making logging requests faster than the underlying appender can process.



2) I read that when using AsyncAppender, it is better to set the
LocationInfo to "false" because otherwise, I'll miss the whole purpose
of improving performance. Well.... I did that, but then I got the
NullPointerException... I have no choice but to remove the %C and %L
from the pattern, right ?


Collecting the information to provide the class and line number is expensive and must be done on the thread that made the logging request. The %C and %L should not have thrown a NullPointerException as you configured them, but they would never be able to give you the class name and line number but should have given you a '?' to indicate that the information was not available.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to