[ 
https://issues.apache.org/jira/browse/LOG4J2-1160?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15185874#comment-15185874
 ] 

Matt Sicker commented on LOG4J2-1160:
-------------------------------------

Then that covers everything. We could probably close this, yes?

> LoggerContext logs with FATAL priority when unable to register a shutdown hook
> ------------------------------------------------------------------------------
>
>                 Key: LOG4J2-1160
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1160
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.4.1
>            Reporter: Oleg Kalnichevski
>
> LoggerContext logs a message at FATAL priority when unable to register a 
> shutdown hook sounds a bit excessive to me. 
> Consider the following scenario: an app is being shut down, it is going 
> through its resource de-allocation and cleanup routines. It loads a new class 
> which has not been used up to this point. The class happens to have a static 
> logger. The logger gets initialized. LoggerContext attempts to register a 
> shutdown hook and fails because the JVM is already being shut down. 
> DefaultShutdownCallbackRegistry throws an ISE which gets logged at FATAL 
> priority. People get a heart attack. Widows and orphans cry.   
> {noformat}
> 2015-10-14 17:50:11,491 Thread-1 FATAL Unable to register shutdown hook 
> because JVM is shutting down. java.lang.IllegalStateException: Cannot add new 
> shutdown hook as this is not started. Current state: STOPPED
>       at 
> org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry.addShutdownCallback(DefaultShutdownCallbackRegistry.java:113)
>       at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.addShutdownCallback(Log4jContextFactory.java:271)
>       at 
> org.apache.logging.log4j.core.LoggerContext.setUpShutdownHook(LoggerContext.java:256)
>       at 
> org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:216)
>       at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:146)
>       at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41)
>       at org.apache.logging.log4j.LogManager.getContext(LogManager.java:185)
>       at 
> org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:103)
>       at 
> org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
>       at 
> org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:42)
>       at 
> org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
>       at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:285)
>       at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:305)
>       at 
> org.apache.activemq.util.ThreadPoolUtils.<clinit>(ThreadPoolUtils.java:31)
>       at 
> org.apache.activemq.ActiveMQConnection.close(ActiveMQConnection.java:728)
>       at 
> org.springframework.jms.connection.SingleConnectionFactory.closeConnection(SingleConnectionFactory.java:456)
>       at 
> org.springframework.jms.connection.SingleConnectionFactory.resetConnection(SingleConnectionFactory.java:345)
>       at 
> org.springframework.jms.connection.SingleConnectionFactory.destroy(SingleConnectionFactory.java:335)
>       at 
> org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:261)
>       at 
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578)
>       at 
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554)
>       at 
> org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:925)
>       at 
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523)
>       at 
> org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:932)
>       at 
> org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:997)
>       at 
> org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:973)
>       at 
> org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:925)
> {noformat}
> I think it is legal for #addShutdownCallback to fail at this point. Logging 
> at  FATAL priority here sounds unwarranted. 
> Could you please consider toning this down a little? Warning maybe?
> Oleg



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to