You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Sudharma Puranik <su...@gmail.com> on 2013/07/18 17:31:13 UTC

Multiple thread creation problem with AsyncAppender

I have a log4j2.xml configuration file from which I am getting the Logger,
attached is the snapshot. when my logger is created a new thread is created.

Programmatically,I create a RollingFileAppender and attach the same to
AsyncAppender . I attach the Async Appender to the configuration of the
log4j.xml, And when I start the Async Appender again a new thread is
created.

The problem now is that both the threads are writing to my async appender
so for a 5 lakh line log, I get 10 lakh lines because each thread is
writing the log.

Is this a bug? because I get a logger a new thread is generated and when I
create a async appender another thread is created and both are doing the
same job.

-Sudharma

Re: Multiple thread creation problem with AsyncAppender

Posted by Sudharma Puranik <su...@gmail.com>.
Ok, I can do that.


On Fri, Jul 19, 2013 at 4:05 AM, Remko Popma <re...@yahoo.com> wrote:

> I'd like to see your log4j.xml. Can you raise a Jira ticket and attach it?
>
> Sent from my iPhone
>
> On 2013/07/19, at 7:34, Remko Popma <re...@yahoo.com> wrote:
>
> > Does your log4j2.xml also define an AsyncAppender?
> >
> > (Btw, what is a lakh?)
> >
> > Sent from my iPhone
> >
> > On 2013/07/19, at 0:31, Sudharma Puranik <su...@gmail.com>
> wrote:
> >
> >> I have a log4j2.xml configuration file from which I am getting the
> Logger, attached is the snapshot. when my logger is created a new thread is
> created.
> >>
> >> Programmatically,I create a RollingFileAppender and attach the same to
> AsyncAppender . I attach the Async Appender to the configuration of the
> log4j.xml, And when I start the Async Appender again a new thread is
> created.
> >>
> >> The problem now is that both the threads are writing to my async
> appender so for a 5 lakh line log, I get 10 lakh lines because each thread
> is writing the log.
> >>
> >> Is this a bug? because I get a logger a new thread is generated and
> when I create a async appender another thread is created and both are doing
> the same job.
> >>
> >> -Sudharma
> >> <asyncAppendThread.png>
> >> <loggerThread.png>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> >> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>
>

Re: Multiple thread creation problem with AsyncAppender

Posted by Remko Popma <re...@yahoo.com>.
I'd like to see your log4j.xml. Can you raise a Jira ticket and attach it?

Sent from my iPhone

On 2013/07/19, at 7:34, Remko Popma <re...@yahoo.com> wrote:

> Does your log4j2.xml also define an AsyncAppender? 
> 
> (Btw, what is a lakh?)
> 
> Sent from my iPhone
> 
> On 2013/07/19, at 0:31, Sudharma Puranik <su...@gmail.com> wrote:
> 
>> I have a log4j2.xml configuration file from which I am getting the Logger, attached is the snapshot. when my logger is created a new thread is created.
>> 
>> Programmatically,I create a RollingFileAppender and attach the same to AsyncAppender . I attach the Async Appender to the configuration of the log4j.xml, And when I start the Async Appender again a new thread is created.
>> 
>> The problem now is that both the threads are writing to my async appender so for a 5 lakh line log, I get 10 lakh lines because each thread is writing the log.
>> 
>> Is this a bug? because I get a logger a new thread is generated and when I create a async appender another thread is created and both are doing the same job.
>> 
>> -Sudharma
>> <asyncAppendThread.png>
>> <loggerThread.png>
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-dev-help@logging.apache.org

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


Re: Multiple thread creation problem with AsyncAppender

Posted by Sudharma Puranik <su...@gmail.com>.
Yes, log4j2.xml also defines a AsyncAppender but which is not mapped to any
logger. Is there a way that I can get the asyncAppender from the
xmlConfiguration and hook my RollingFileAppender? I did not find any such
convenience.

Why is handling of Appenders in log4j2 not straightforward? Or probably If
i am not aware can you please help me.

Regarding Lakh, I meant , 5Lakh lines inside my log file, which I am
printing in a for loop for my testing.:-)

-Sudharma


On Fri, Jul 19, 2013 at 4:03 AM, Remko Popma <re...@yahoo.com> wrote:

> Does your log4j2.xml also define an AsyncAppender?
>
> (Btw, what is a lakh?)
>
> Sent from my iPhone
>
> On 2013/07/19, at 0:31, Sudharma Puranik <su...@gmail.com>
> wrote:
>
> > I have a log4j2.xml configuration file from which I am getting the
> Logger, attached is the snapshot. when my logger is created a new thread is
> created.
> >
> > Programmatically,I create a RollingFileAppender and attach the same to
> AsyncAppender . I attach the Async Appender to the configuration of the
> log4j.xml, And when I start the Async Appender again a new thread is
> created.
> >
> > The problem now is that both the threads are writing to my async
> appender so for a 5 lakh line log, I get 10 lakh lines because each thread
> is writing the log.
> >
> > Is this a bug? because I get a logger a new thread is generated and when
> I create a async appender another thread is created and both are doing the
> same job.
> >
> > -Sudharma
> > <asyncAppendThread.png>
> > <loggerThread.png>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> > For additional commands, e-mail: log4j-dev-help@logging.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>
>

Re: Multiple thread creation problem with AsyncAppender

Posted by Remko Popma <re...@yahoo.com>.
Does your log4j2.xml also define an AsyncAppender? 

(Btw, what is a lakh?)

Sent from my iPhone

On 2013/07/19, at 0:31, Sudharma Puranik <su...@gmail.com> wrote:

> I have a log4j2.xml configuration file from which I am getting the Logger, attached is the snapshot. when my logger is created a new thread is created.
> 
> Programmatically,I create a RollingFileAppender and attach the same to AsyncAppender . I attach the Async Appender to the configuration of the log4j.xml, And when I start the Async Appender again a new thread is created.
> 
> The problem now is that both the threads are writing to my async appender so for a 5 lakh line log, I get 10 lakh lines because each thread is writing the log.
> 
> Is this a bug? because I get a logger a new thread is generated and when I create a async appender another thread is created and both are doing the same job.
> 
> -Sudharma
> <asyncAppendThread.png>
> <loggerThread.png>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-dev-help@logging.apache.org

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