LifeCycleBean problem/question

classic Classic list List threaded Threaded
3 messages Options
Mikael Mikael
Reply | Threaded
Open this post in threaded view
|

LifeCycleBean problem/question

Hi!

I gave up on the JUL logging so I went back to log4j 2, this works
better but there is still very weird behavior.

I run my code as a LifeCycleBean and all works fine, but the moment that
LifeCyclebean::BEFORE_NODE_STOP event is called the log4j 2 logger is
shutdown, if I turn on log4j2.debug=true I see:

"DEBUG StatusLogger Stopping LoggerContext[name=,
org.apache.logging.log4j.core.LoggerContext@543588e6]" just when the
BEFORE_NODE_STOP event is executed and any logging after that is lost,
it looks like the shutdown hook log4j 2 install is executed at that time
looking at the source code but how is that possible ? I would assume I
am doing something silly as I have not heard any one else complain about
this, any idea what it could be ?

This all standard log4j2 logging out of the box, I do have a Cassandra
client running with slf4j->log4j2 setup in the same application, but I
do not think that has anything to do with it and I shutdown the
Cassandra client in the AFTER_NODE_STOP event later on.

Mikael




ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: LifeCycleBean problem/question

Hello!

I don't think this should happen? Can you add breakpoint to this method (LogManager.shutdown), share stack trace with us once it gets hit?

Regards,
--
Ilya Kasnacheev


вт, 8 окт. 2019 г. в 23:44, Mikael <[hidden email]>:
Hi!

I gave up on the JUL logging so I went back to log4j 2, this works
better but there is still very weird behavior.

I run my code as a LifeCycleBean and all works fine, but the moment that
LifeCyclebean::BEFORE_NODE_STOP event is called the log4j 2 logger is
shutdown, if I turn on log4j2.debug=true I see:

"DEBUG StatusLogger Stopping LoggerContext[name=,
org.apache.logging.log4j.core.LoggerContext@543588e6]" just when the
BEFORE_NODE_STOP event is executed and any logging after that is lost,
it looks like the shutdown hook log4j 2 install is executed at that time
looking at the source code but how is that possible ? I would assume I
am doing something silly as I have not heard any one else complain about
this, any idea what it could be ?

This all standard log4j2 logging out of the box, I do have a Cassandra
client running with slf4j->log4j2 setup in the same application, but I
do not think that has anything to do with it and I shutdown the
Cassandra client in the AFTER_NODE_STOP event later on.

Mikael




Mikael Mikael
Reply | Threaded
Open this post in threaded view
|

Re: LifeCycleBean problem/question

Hi!

I figured it out, when I test I use CTRL+C to stop the node and that makes the log4j2 builtin shutdown hook to execute and it looks it is executed in parallel with the jvm shutdown hooks and before Ignite is finished with shutdown, so I disabled log4j2's shutdown hook (-Dlog4j.shutdownHookEnabled=false) and then do a LogManager.shutdown() at the end of Ignites AFTER_NODE_STOP event is complete and now it works just fine.

Mikael


Den 2019-10-09 kl. 10:54, skrev Ilya Kasnacheev:
Hello!

I don't think this should happen? Can you add breakpoint to this method (LogManager.shutdown), share stack trace with us once it gets hit?

Regards,
--
Ilya Kasnacheev


вт, 8 окт. 2019 г. в 23:44, Mikael <[hidden email]>:
Hi!

I gave up on the JUL logging so I went back to log4j 2, this works
better but there is still very weird behavior.

I run my code as a LifeCycleBean and all works fine, but the moment that
LifeCyclebean::BEFORE_NODE_STOP event is called the log4j 2 logger is
shutdown, if I turn on log4j2.debug=true I see:

"DEBUG StatusLogger Stopping LoggerContext[name=,
org.apache.logging.log4j.core.LoggerContext@543588e6]" just when the
BEFORE_NODE_STOP event is executed and any logging after that is lost,
it looks like the shutdown hook log4j 2 install is executed at that time
looking at the source code but how is that possible ? I would assume I
am doing something silly as I have not heard any one else complain about
this, any idea what it could be ?

This all standard log4j2 logging out of the box, I do have a Cassandra
client running with slf4j->log4j2 setup in the same application, but I
do not think that has anything to do with it and I shutdown the
Cassandra client in the AFTER_NODE_STOP event later on.

Mikael