You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Feigin Yaron <Ya...@comverse.com> on 2006/12/29 08:00:58 UTC

Thread blocking problem

Hi all,
 
We are writing a pure Java server that manages some flow threads - Each thread reads a packet from the network, parses it and runs the relevant flow according to the recognized message...
We are using the log4j as the logging mechanism agent and bumped into a blocking problem...
As each thread tries to print log messages over its flow, it sits and waits for its turn to append the log event to a file via the appender mechanism synchronically...
The problem occurs when we are at a heavy load, a printing thread can sit more than 8 seconds and wait for its turn...
Is there a way ,each thread would append the log-event to a non-blocking queue and returns immediatedltly after it has put the event in the queue and continue its flow?
I know, the log4j has an asynchappender we may use - Is it safe to use? Does it serves our purposes?
As we are using only one type of appender, the recommendation in the log4j manual, was not to use the asynchappender but only if u have multiple appenders...
I will appreciate if someone can reply and suggests an idea to solve this...
Many thanks in advance,
 
Yaron Feigin

Re: Thread blocking problem

Posted by James Stauffer <st...@gmail.com>.
In the most recent version AsyncAppender is supposed to work well and
would probably meet your needs.

On 12/29/06, Feigin Yaron <Ya...@comverse.com> wrote:
> Hi all,
>
> We are writing a pure Java server that manages some flow threads - Each thread reads a packet from the network, parses it and runs the relevant flow according to the recognized message...
> We are using the log4j as the logging mechanism agent and bumped into a blocking problem...
> As each thread tries to print log messages over its flow, it sits and waits for its turn to append the log event to a file via the appender mechanism synchronically...
> The problem occurs when we are at a heavy load, a printing thread can sit more than 8 seconds and wait for its turn...
> Is there a way ,each thread would append the log-event to a non-blocking queue and returns immediatedltly after it has put the event in the queue and continue its flow?
> I know, the log4j has an asynchappender we may use - Is it safe to use? Does it serves our purposes?
> As we are using only one type of appender, the recommendation in the log4j manual, was not to use the asynchappender but only if u have multiple appenders...
> I will appreciate if someone can reply and suggests an idea to solve this...
> Many thanks in advance,
>
> Yaron Feigin
>
>


-- 
James Stauffer        http://www.geocities.com/stauffer_james/
Are you good? Take the test at http://www.livingwaters.com/good/

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org