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 ?



-----Original Message-----
From: Curt Arnold [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 18, 2006 4:10 PM
To: Cohen Oren (ICS)
Subject: Re: Multiple threads that log events to the same file
concurrently



On Oct 18, 2006, at 5:49 AM, Cohen Oren (ICS) wrote:

> Thanks a lot Curt !
> I appreciate your quick reply.
>
> I'm currently using 1.2.7 version.
>
> 1) Referring to the first sentence you wrote, how can my log4j do the 
> threshold checks concurrently, if I saw that
> AppenderSkeleton.doAppend()
> method is synchronized ? That's the method who's responsible for these

> checks (at least in 1.2.7) , no ?

Category.debug() et al all check threshold before calling
Category.forcedLog which both should be outside the scope of a
synchronization block.

>
> 2) Before I upgrade, can you address me to a link which details the 
> major changes that were done between my version (1.2.7) and 1.2.14 ?

The log4j release contains a file docs/HISTORY.txt that will describe
the changes between all versions.  It can also be accessed at http://
svn.apache.org/repos/asf/logging/log4j/branches/v1_2-branch/docs/
HISTORY.txt.


>
> 3) What do you think about the following solution :
> Each thread will have a logging queue, for example: a LinkedList of 
> LoggingEvent objects.
> Each of my threads will append its logging events into its own logging

> queue. A new dispatcher thread that I will write, will go over these 
> queues (round-robin), get the objects and log them to one FileAppender

> using log4j.
> This is my current favorite solution, but I'm writing it to you in 
> case my solution is already implemented better in log4j and I don't 
> know about it.
>
> Thanks a lot !!!
>
>

I would recommend staying with the AsyncAppender in log4j 1.2.14.   
Since log4j is going to force you to be in a synchronization block
during the append, there is no benefit of using distinct event queues
per thread.  That type of code is hard to write right.

If you have any more questions, please ask them on log4j-user.

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

Reply via email to