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 Mickael Marrache <mi...@gmail.com> on 2014/09/18 18:53:38 UTC

Ignoring log event after log4j was shut down

Hi,

 

I just started to use Log4j 2 with the asynchronous logger feature, I
followed the guide but after a running a unit test, I always get the
following log entry at the end instead of the last line I expect:

 

2014-09-18 16:45:56,030 FATAL Ignoring log event after log4j was shut down

 

If I disable remove the Log4jContextSelector  system property, I can see the
last log entry instead of the error.

 

I guess the log4j engine is shut down and therefore it ignores the log
entry? If yes, why it is not shut down after the test ends?

 

Regards,

Mickael


Re: Ignoring log event after log4j was shut down

Posted by Remko Popma <re...@gmail.com>.
Logically they are equivalent but their implementation is slightly
different. The one you're using now can handle reconfiguration better. This
is on the todo list.

About your other question: You only need to use one async mechanism. If you
use two (say, async loggers + async appenders) you'll get two queues and
two background threads. That just adds an extra step before your event is
written to disk. This is not a problem but also not helpful.

On Friday, September 19, 2014, Mickael Marrache <mi...@gmail.com>
wrote:

> Using <AsyncRoot> and <AsyncLogger> solved the issue. Logically, there
> should not be differences since I configured all the loggers to be
> asynchronous.
>
> I just understood the "asynchronous" nature applies for loggers and
> appenders. If all the loggers are asynchronous, is it needed to use
> asynchronous appenders?
>
> -----Original Message-----
> From: Remko Popma [mailto:remko.popma@gmail.com <javascript:;>]
> Sent: Thursday, September 18, 2014 8:18 PM
> To: Log4J Users List
> Subject: Re: Ignoring log event after log4j was shut down
>
> I suspect that SprintJUnit4ClassRunner does some classloading magic and
> that you are suffering the same problem as this:
> https://issues.apache.org/jira/browse/LOG4J2-493
>
> There are two ways to configure async loggers: with the context selector
> system property, and in log4j2.xml with <AsyncRoot> and <AsyncLogger>
> elements.
> Can you try removing the context selector system property and instead use
> <AsyncRoot> and <AsyncLogger> in your log4j2 configuration?
>
>
> On Fri, Sep 19, 2014 at 2:05 AM, Mickael Marrache <
> mickaelmarrache@gmail.com <javascript:;>
> > wrote:
>
> > Yes I run my unit test from Eclipse. I use the SpringJUnit4ClassRunner
> > runner to load my application context, I don't think it registers the
> > Spring shutdown hook.
> >
> > -----Original Message-----
> > From: Remko Popma [mailto:remko.popma@gmail.com <javascript:;>]
> > Sent: Thursday, September 18, 2014 7:58 PM
> > To: Log4J Users List
> > Subject: Re: Ignoring log event after log4j was shut down
> >
> > How are you running this unit test? (From an IDE (which one), from a
> > Maven/Ant build or from the command line, ...?) Do you have any
> > shutdown hooks and does logging take place inside a shutdown hook?
> >
> > On Fri, Sep 19, 2014 at 1:53 AM, Mickael Marrache <
> > mickaelmarrache@gmail.com <javascript:;>
> > > wrote:
> >
> > > Hi,
> > >
> > >
> > >
> > > I just started to use Log4j 2 with the asynchronous logger feature,
> > > I followed the guide but after a running a unit test, I always get
> > > the following log entry at the end instead of the last line I expect:
> > >
> > >
> > >
> > > 2014-09-18 16:45:56,030 FATAL Ignoring log event after log4j was
> > > shut down
> > >
> > >
> > >
> > > If I disable remove the Log4jContextSelector  system property, I can
> > > see the last log entry instead of the error.
> > >
> > >
> > >
> > > I guess the log4j engine is shut down and therefore it ignores the
> > > log entry? If yes, why it is not shut down after the test ends?
> > >
> > >
> > >
> > > Regards,
> > >
> > > Mickael
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> <javascript:;>
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
> <javascript:;>
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> <javascript:;>
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> <javascript:;>
>
>

RE: Ignoring log event after log4j was shut down

Posted by Mickael Marrache <mi...@gmail.com>.
Using <AsyncRoot> and <AsyncLogger> solved the issue. Logically, there should not be differences since I configured all the loggers to be asynchronous.

I just understood the "asynchronous" nature applies for loggers and appenders. If all the loggers are asynchronous, is it needed to use asynchronous appenders?

-----Original Message-----
From: Remko Popma [mailto:remko.popma@gmail.com] 
Sent: Thursday, September 18, 2014 8:18 PM
To: Log4J Users List
Subject: Re: Ignoring log event after log4j was shut down

I suspect that SprintJUnit4ClassRunner does some classloading magic and that you are suffering the same problem as this:
https://issues.apache.org/jira/browse/LOG4J2-493

There are two ways to configure async loggers: with the context selector system property, and in log4j2.xml with <AsyncRoot> and <AsyncLogger> elements.
Can you try removing the context selector system property and instead use <AsyncRoot> and <AsyncLogger> in your log4j2 configuration?


On Fri, Sep 19, 2014 at 2:05 AM, Mickael Marrache <mickaelmarrache@gmail.com
> wrote:

> Yes I run my unit test from Eclipse. I use the SpringJUnit4ClassRunner 
> runner to load my application context, I don't think it registers the 
> Spring shutdown hook.
>
> -----Original Message-----
> From: Remko Popma [mailto:remko.popma@gmail.com]
> Sent: Thursday, September 18, 2014 7:58 PM
> To: Log4J Users List
> Subject: Re: Ignoring log event after log4j was shut down
>
> How are you running this unit test? (From an IDE (which one), from a 
> Maven/Ant build or from the command line, ...?) Do you have any 
> shutdown hooks and does logging take place inside a shutdown hook?
>
> On Fri, Sep 19, 2014 at 1:53 AM, Mickael Marrache < 
> mickaelmarrache@gmail.com
> > wrote:
>
> > Hi,
> >
> >
> >
> > I just started to use Log4j 2 with the asynchronous logger feature, 
> > I followed the guide but after a running a unit test, I always get 
> > the following log entry at the end instead of the last line I expect:
> >
> >
> >
> > 2014-09-18 16:45:56,030 FATAL Ignoring log event after log4j was 
> > shut down
> >
> >
> >
> > If I disable remove the Log4jContextSelector  system property, I can 
> > see the last log entry instead of the error.
> >
> >
> >
> > I guess the log4j engine is shut down and therefore it ignores the 
> > log entry? If yes, why it is not shut down after the test ends?
> >
> >
> >
> > Regards,
> >
> > Mickael
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>


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


Re: Ignoring log event after log4j was shut down

Posted by Remko Popma <re...@gmail.com>.
I suspect that SprintJUnit4ClassRunner does some classloading magic and
that you are suffering the same problem as this:
https://issues.apache.org/jira/browse/LOG4J2-493

There are two ways to configure async loggers: with the context selector
system property, and in log4j2.xml with <AsyncRoot> and <AsyncLogger>
elements.
Can you try removing the context selector system property and instead use
<AsyncRoot> and <AsyncLogger> in your log4j2 configuration?


On Fri, Sep 19, 2014 at 2:05 AM, Mickael Marrache <mickaelmarrache@gmail.com
> wrote:

> Yes I run my unit test from Eclipse. I use the SpringJUnit4ClassRunner
> runner to load my application context, I don't think it registers the
> Spring shutdown hook.
>
> -----Original Message-----
> From: Remko Popma [mailto:remko.popma@gmail.com]
> Sent: Thursday, September 18, 2014 7:58 PM
> To: Log4J Users List
> Subject: Re: Ignoring log event after log4j was shut down
>
> How are you running this unit test? (From an IDE (which one), from a
> Maven/Ant build or from the command line, ...?) Do you have any shutdown
> hooks and does logging take place inside a shutdown hook?
>
> On Fri, Sep 19, 2014 at 1:53 AM, Mickael Marrache <
> mickaelmarrache@gmail.com
> > wrote:
>
> > Hi,
> >
> >
> >
> > I just started to use Log4j 2 with the asynchronous logger feature, I
> > followed the guide but after a running a unit test, I always get the
> > following log entry at the end instead of the last line I expect:
> >
> >
> >
> > 2014-09-18 16:45:56,030 FATAL Ignoring log event after log4j was shut
> > down
> >
> >
> >
> > If I disable remove the Log4jContextSelector  system property, I can
> > see the last log entry instead of the error.
> >
> >
> >
> > I guess the log4j engine is shut down and therefore it ignores the log
> > entry? If yes, why it is not shut down after the test ends?
> >
> >
> >
> > Regards,
> >
> > Mickael
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

RE: Ignoring log event after log4j was shut down

Posted by Mickael Marrache <mi...@gmail.com>.
Yes I run my unit test from Eclipse. I use the SpringJUnit4ClassRunner runner to load my application context, I don't think it registers the Spring shutdown hook.

-----Original Message-----
From: Remko Popma [mailto:remko.popma@gmail.com] 
Sent: Thursday, September 18, 2014 7:58 PM
To: Log4J Users List
Subject: Re: Ignoring log event after log4j was shut down

How are you running this unit test? (From an IDE (which one), from a Maven/Ant build or from the command line, ...?) Do you have any shutdown hooks and does logging take place inside a shutdown hook?

On Fri, Sep 19, 2014 at 1:53 AM, Mickael Marrache <mickaelmarrache@gmail.com
> wrote:

> Hi,
>
>
>
> I just started to use Log4j 2 with the asynchronous logger feature, I 
> followed the guide but after a running a unit test, I always get the 
> following log entry at the end instead of the last line I expect:
>
>
>
> 2014-09-18 16:45:56,030 FATAL Ignoring log event after log4j was shut 
> down
>
>
>
> If I disable remove the Log4jContextSelector  system property, I can 
> see the last log entry instead of the error.
>
>
>
> I guess the log4j engine is shut down and therefore it ignores the log 
> entry? If yes, why it is not shut down after the test ends?
>
>
>
> Regards,
>
> Mickael
>
>


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


Re: Ignoring log event after log4j was shut down

Posted by Remko Popma <re...@gmail.com>.
How are you running this unit test? (From an IDE (which one), from a
Maven/Ant build or from the command line, ...?)
Do you have any shutdown hooks and does logging take place inside a
shutdown hook?

On Fri, Sep 19, 2014 at 1:53 AM, Mickael Marrache <mickaelmarrache@gmail.com
> wrote:

> Hi,
>
>
>
> I just started to use Log4j 2 with the asynchronous logger feature, I
> followed the guide but after a running a unit test, I always get the
> following log entry at the end instead of the last line I expect:
>
>
>
> 2014-09-18 16:45:56,030 FATAL Ignoring log event after log4j was shut down
>
>
>
> If I disable remove the Log4jContextSelector  system property, I can see
> the
> last log entry instead of the error.
>
>
>
> I guess the log4j engine is shut down and therefore it ignores the log
> entry? If yes, why it is not shut down after the test ends?
>
>
>
> Regards,
>
> Mickael
>
>