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

Robert Neßelrath edited comment on LOG4J2-1902 at 12/13/17 1:07 PM:
--------------------------------------------------------------------

I have the same problem. The property `-Dlog4j.shutdownHookEnabled=false` is 
just ignored and has no effect, I still get the log message:

_Shutdown hook enabled. Registering a new one._

If I set the attribute shutdownHook="disable" in my configuration file, the 
property is correctly parsed. I assume the problem lies in the LoggerContext 
itself:

{quote}public void start(final Configuration config) {
        LOGGER.debug("Starting LoggerContext[name={}, {}] with configuration 
{}...", getName(), this, config);
        if (configLock.tryLock()) {
            try {
                if (this.isInitialized() || this.isStopped()) {
                    if (this.configuration.isShutdownHookEnabled()) {
                        setUpShutdownHook();
                    }
                    this.setStarted();
                }
            } finally {
                configLock.unlock();
            }
        }
        setConfiguration(config);
        LOGGER.debug("LoggerContext[name={}, {}] started OK with configuration 
{}.", getName(), this, config);
    }{quote}

Here my xml configuration is set after the shutdown hook has been registered.


was (Author: rnesselrath):
I have the same problem. The property `-Dlog4j.shutdownHookEnabled=false` is 
just ignored and has no effect, I still get the log message:

_Shutdown hook enabled. Registering a new one._

If I set the attribute shutdownHook="disable" in my configuration file, the 
property is correctly parsed. I assume the problem lies in the LoggerContext 
itself:

{{ 
public void start(final Configuration config) {
        LOGGER.debug("Starting LoggerContext[name={}, {}] with configuration 
{}...", getName(), this, config);
        if (configLock.tryLock()) {
            try {
                if (this.isInitialized() || this.isStopped()) {
                    if (this.configuration.isShutdownHookEnabled()) {
                        setUpShutdownHook();
                    }
                    this.setStarted();
                }
            } finally {
                configLock.unlock();
            }
        }
        setConfiguration(config);
        LOGGER.debug("LoggerContext[name={}, {}] started OK with configuration 
{}.", getName(), this, config);
    }
}}

Here my xml configuration is set after the shutdown hook has been registered.

> log4j2-web does not disable shutdownHook
> ----------------------------------------
>
>                 Key: LOG4J2-1902
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1902
>             Project: Log4j 2
>          Issue Type: Question
>    Affects Versions: 2.5, 2.8.2
>         Environment: Mac OS,
> JDK 1.8
> log4j2 2.5 and 2.8.2
>            Reporter: prayagupd
>
> I'm using log4j2 2.8.2 and with log4j-web, the shutdown hook is supposed to 
> disabled automatically. 
> {code:xml}
>     <dependency>
>       <groupId>org.apache.logging.log4j</groupId>
>       <artifactId>log4j-web</artifactId>
>       <version>2.8.2</version>
>       <scope>compile</scope>
>     </dependency>
> {code}
> On trace mode, I still see the log saying its enabled, 
> {code}
> 2017-05-07 14:56:34,762 ScalaTest-run DEBUG Reconfiguration complete for 
> context[name=1b4fb997] at URI 
> /Users/prayagupd/possibilities/programming/event-streaming/target/test-classes/log4j2.json
>  (org.apache.logging.log4j.core.LoggerContext@205b132e) with optional 
> ClassLoader: null
> 2017-05-07 14:56:34,762 ScalaTest-run DEBUG Shutdown hook enabled. 
> Registering a new one.
> 2017-05-07 14:56:34,762 ScalaTest-run DEBUG LoggerContext[name=1b4fb997, 
> org.apache.logging.log4j.core.LoggerContext@205b132e] started OK.
> {code}
> The log4j2 config, 
> {code:javascript}
> {
>   "configuration": {
>     "name": "logggg",
>     "status" : "trace",
>     "shutdownHookEnabled" : false,
>     "appenders": {
>       "RollingFile": {
>         "name": "rollingStone",
>         "fileName": "event-consumer-specs.log",
>         "filePattern": "event-consumer-specs-%d{MM-dd-yy-HH-mm-ss}-%i.log",
>         "immediateFlush" : true,
>         "JSONLayout": {
>           "complete": false,
>           "compact": true,
>           "eventEol": true
>         },
>         "SizeBasedTriggeringPolicy": {
>           "size": "10 MB"
>         },
>         "DefaultRolloverStrategy": {
>           "max": "10"
>         }
>       }
>     },
>     "loggers": {
>       "root": {
>         "level": "debug",
>         "appender-ref": {
>           "ref": "rollingStone"
>         }
>       }
>     }
>   }
> }
> {code}
> I want to disable the shutdown hook, as I'm having trouble in tomcat 7, 
> websphere 8, as app logs nothing to the file. The way I'm making it work is 
> restarting the application container, which is causing downtime to other 
> services running on the same container.
> The doc https://logging.apache.org/log4j/2.x/manual/webapp.html says 
> log4j2-web jar is what disables the shutdown hook but not working for me.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to