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 Gary Gregory <ga...@gmail.com> on 2016/01/24 22:43:32 UTC

Fwd: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Resending, got a error from my phone...
---------- Forwarded message ----------
From: "Gary Gregory" <ga...@gmail.com>
Date: Jan 24, 2016 1:41 PM
Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods
to LogManager
To: <de...@logging.apache.org>
Cc:

Hi all,

Any reason not use the usual -able postfix instead of ShutdownCapable:
Shutdownable sounds too weird? What about reusing plain old Closeable? That
means you could use the context in a try-with-resources block, a bonus.

Gary
On Jan 24, 2016 10:18 AM, <rg...@apache.org> wrote:

> Repository: logging-log4j2
> Updated Branches:
>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>
>
> LOG4J2-124 - Add shutdown methods to LogManager
>
>
> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
> Commit:
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7
> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7
> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7
>
> Branch: refs/heads/master
> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
> Parents: 7d3aac4
> Author: Ralph Goers <rg...@nextiva.com>
> Authored: Sun Jan 24 11:18:41 2016 -0700
> Committer: Ralph Goers <rg...@nextiva.com>
> Committed: Sun Jan 24 11:18:41 2016 -0700
>
> ----------------------------------------------------------------------
>  .../org/apache/logging/log4j/LogManager.java    | 62 ++++++++++++++++++++
>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>  4 files changed, 93 insertions(+), 1 deletion(-)
> ----------------------------------------------------------------------
>
>
>
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
> ----------------------------------------------------------------------
> diff --git
> a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
> b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
> index f10e5a8..64c6ee5 100644
> --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
> @@ -27,6 +27,7 @@ import
> org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>  import org.apache.logging.log4j.spi.LoggerContext;
>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>  import org.apache.logging.log4j.spi.Provider;
> +import org.apache.logging.log4j.spi.ShutdownCapable;
>  import org.apache.logging.log4j.status.StatusLogger;
>  import org.apache.logging.log4j.util.LoaderUtil;
>  import org.apache.logging.log4j.util.PropertiesUtil;
> @@ -285,6 +286,67 @@ public class LogManager {
>      }
>
>      /**
> +     * Shutdown using the default LoggerContext.
> +     * @since 2.6
> +     */
> +    public static void shutdown() {
> +        shutdown(getContext());
> +    }
> +
> +    /**
> +     * Shutdown the logging system if the logging system supports it.
> +     * @param currentContext if true the LoggerContext for the caller of
> this method will be used.
> +     * @since 2.6
> +     */
> +    public static void shutdown(boolean currentContext) {
> +        shutdown(getContext(currentContext));
> +    }
> +
> +    /**
> +     * Shutdown the logging system if the logging system supports it.
> +     * @param loader The ClassLoader for the context. If null the context
> will attempt to determine the appropriate
> +     *            ClassLoader.
> +     * @param currentContext if false the LoggerContext appropriate for
> the caller of this method will be used.
> +     * @since 2.6
> +     */
> +    public static void shutdown(final ClassLoader loader, final boolean
> currentContext) {
> +        shutdown(getContext(loader, currentContext));
> +    }
> +
> +    /**
> +     * Shutdown the logging system if the logging system supports it.
> +     * @param context the LoggerContext.
> +     * @since 2.6
> +     */
> +    public static void shutdown(LoggerContext context) {
> +        if (context != null && context instanceof ShutdownCapable) {
> +            ((ShutdownCapable) context).shutdown();
> +        }
> +    }
> +
> +    /**
> +     * Shutdown the logging system if the logging system supports it.
> +     * @param fqcn The fully qualified class name of the Class that this
> method is a member of.
> +     * @param currentContext if false the LoggerContext appropriate for
> the caller of this method will be used.
> +     * @since 2.6
> +     */
> +    protected static void shutdown(final String fqcn, final boolean
> currentContext) {
> +        shutdown(getContext(fqcn, currentContext));
> +    }
> +
> +    /**
> +     * Shutdown the logging system if the logging system supports it.
> +     * @param fqcn The fully qualified class name of the Class that this
> method is a member of.
> +     * @param loader The ClassLoader for the context. If null the context
> will attempt to determine the appropriate
> +     *            ClassLoader.
> +     * @param currentContext if false the LoggerContext appropriate for
> the caller of this method will be used.
> +     * @since 2.6
> +     */
> +    protected static void shutdown(final String fqcn, final ClassLoader
> loader, final boolean currentContext) {
> +        shutdown(getContext(fqcn, loader, currentContext));
> +    }
> +
> +    /**
>       * Returns the current LoggerContextFactory.
>       *
>       * @return The LoggerContextFactory.
>
>
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
> ----------------------------------------------------------------------
> diff --git
> a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
> new file mode 100644
> index 0000000..a46ef60
> --- /dev/null
> +++
> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
> @@ -0,0 +1,17 @@
> +/*
> + * Copyright (c) 2016 Nextiva, Inc. to Present.
> + * All rights reserved.
> + */
> +package org.apache.logging.log4j.spi;
> +
> +/**
> + * Interface to be implemented by LoggerContext's that provide a shutdown
> method.
> + * @since 2.6
> + */
> +public interface ShutdownCapable {
> +
> +    /**
> +     * Requests that the logging implementation shut down.
> +     */
> +    void shutdown();
> +}
>
>
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
> ----------------------------------------------------------------------
> diff --git
> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
> index 48f0eea..596a9f2 100644
> --- a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
> +++ b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
> @@ -17,6 +17,7 @@
>  package org.apache.logging.log4j;
>
>  import org.apache.logging.log4j.message.ParameterizedMessageFactory;
> +import org.apache.logging.log4j.spi.LoggerContext;
>  import org.junit.Test;
>
>  import static org.junit.Assert.*;
> @@ -53,4 +54,10 @@ public class LogManagerTest {
>          assertNotNull("No Logger returned", logger);
>          assertTrue("Incorrect Logger name: " +
> logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>      }
> +
> +    @Test
> +    public void testShutdown() {
> +        LoggerContext loggerContext = LogManager.getContext(false);
> +        LogManager.shutdown(loggerContext);
> +    }
>  }
>
>
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
> ----------------------------------------------------------------------
> diff --git
> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
> index 42efbb5..fcdfc16 100644
> ---
> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
> +++
> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
> @@ -45,6 +45,7 @@ import org.apache.logging.log4j.message.MessageFactory;
>  import org.apache.logging.log4j.spi.AbstractLogger;
>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>  import org.apache.logging.log4j.spi.LoggerContextKey;
> +import org.apache.logging.log4j.spi.ShutdownCapable;
>
>  import static
> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>
> @@ -54,7 +55,7 @@ import static
> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>   * filters, etc and will be atomically updated whenever a reconfigure
> occurs.
>   */
>  public class LoggerContext extends AbstractLifeCycle implements
> org.apache.logging.log4j.spi.LoggerContext,
> -        ConfigurationListener {
> +        ShutdownCapable, ConfigurationListener {
>
>      /**
>       * Property name of the property change event fired if the
> configuration is changed.
> @@ -278,6 +279,11 @@ public class LoggerContext extends AbstractLifeCycle
> implements org.apache.loggi
>      }
>
>      @Override
> +    public void shutdown() {
> +        stop();
> +    }
> +
> +    @Override
>      public void stop() {
>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...", getName(),
> this);
>          configLock.lock();
>
>

Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Ralph Goers <ra...@dslextreme.com>.
Log4j 2 already has a way to disable the shutdown hook.  It also already has a way to allow you to manually shutdown via Configurator.shutdown(). We are simply trying to add the api method to LogManager - which requires a change to the API’s LoggerContext.

Ralph

> On Jan 25, 2016, at 5:06 PM, Guido Medina <ox...@gmail.com> wrote:
> 
> Due to current implementation I think start lazy shouldn't be changed or else you will introduce another life-cycle mayhem, instead add a configuration property to enable/disable shutdown hook and add stop method:
> 
> I have micro-services in Akka for example with ActorSystem.shutdown under a JVM shutdown hook and sometimes Log4j2 stops before Akka, in that scenario I would like to disable Log4j2 shutdown hook and call stop myself.
> 
> Hope that makes sense,
> 
> Guido.
> 
> On Tue, Jan 26, 2016 at 12:00 AM, Matt Sicker <boards@gmail.com <ma...@gmail.com>> wrote:
> Lifecycle/LifeCycle is the closest thing I see already in log4j and Spring. Camel has an interface called ShutdownableService which is similar (but extends their Service interface).
> 
> Other projects:
> * CXF uses the Bus interface which has a shutdown method.
> * OSGi has Bundle.stop() which is rather similar to a generic Lifecycle interface overall
> * Hadoop has a Service interface with a stop() method
> * Tomcat as a Lifecycle interface with a stop() method
> 
> I mean the basic idea I'm seeing here is that nobody seems to make a class with a stop-style method without an accompanying start-style method.
> 
> On 25 January 2016 at 17:35, Gary Gregory <garydgregory@gmail.com <ma...@gmail.com>> wrote:
> I see some interfaces with "*Capable*" in the name here and there in the FOSS world (but not in the JRE) so I am a little more comfortable with it. 
> 
> I still see plain old "Shutdown" as simpler. 
> 
> I think I've boiled down my feel for this name to the fact that the Capable postfix is redundant since a class implementing any interface is "capable" of that functionality. IOW we have Serializable vs. SerializationCabable, which means the same thing.
> 
> Gary
> 
> On Mon, Jan 25, 2016 at 7:27 AM, Ralph Goers <ralph.goers@dslextreme.com <ma...@dslextreme.com>> wrote:
> What does it feel weird to you?  To be honest, I originally named the interface ‘Shutdown” and then changed it since it really is about implementing a behavior and “Shutdown” alone doesn’t really describe that.
> 
> Ralph
> 
>> On Jan 24, 2016, at 11:09 PM, Gary Gregory <garydgregory@gmail.com <ma...@gmail.com>> wrote:
>> 
>> On Sun, Jan 24, 2016 at 10:07 PM, Gary Gregory <garydgregory@gmail.com <ma...@gmail.com>> wrote:
>> On Sun, Jan 24, 2016 at 1:54 PM, Ralph Goers <ralph.goers@dslextreme.com <ma...@dslextreme.com>> wrote:
>> Yes, Shutdownable is too weird. 
>> 
>> How about calling it simply "Shutdown" then? FooCapable feels weird to me.
>> 
>> Can anyone think of other (one-method or not) optional feature-like interfaces in the JRE or other code base?
>> 
>> hm... ShutdownService?
>> 
>> Gary
>>  
>> 
>> Gary
>> 
>> Closeable would imply there is a close method, not a shutdown method.  I have my doubts about the try-with-resources use case here.  Virtually all usages are probably going to be to disable automatic shutdown and then the user placing the shutdown call somewhere they can control, which probably will have nothing to do with initialization of logging. 
>> 
>> Ralph
>> 
>>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <garydgregory@gmail.com <ma...@gmail.com>> wrote:
>>> 
>>> Resending, got a error from my phone...
>>> 
>>> ---------- Forwarded message ----------
>>> From: "Gary Gregory" <garydgregory@gmail.com <ma...@gmail.com>>
>>> Date: Jan 24, 2016 1:41 PM
>>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager
>>> To: <dev@logging.apache.org <ma...@logging.apache.org>>
>>> Cc: 
>>> 
>>> Hi all,
>>> 
>>> Any reason not use the usual -able postfix instead of ShutdownCapable: Shutdownable sounds too weird? What about reusing plain old Closeable? That means you could use the context in a try-with-resources block, a bonus.
>>> 
>>> Gary 
>>> 
>>> On Jan 24, 2016 10:18 AM, <rgoers@apache.org <ma...@apache.org>> wrote:
>>> Repository: logging-log4j2
>>> Updated Branches:
>>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>>> 
>>> 
>>> LOG4J2-124 - Add shutdown methods to LogManager
>>> 
>>> 
>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo <http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo>
>>> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7>
>>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7>
>>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7>
>>> 
>>> Branch: refs/heads/master
>>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>>> Parents: 7d3aac4
>>> Author: Ralph Goers <rgoers@nextiva.com <ma...@nextiva.com>>
>>> Authored: Sun Jan 24 11:18:41 2016 -0700
>>> Committer: Ralph Goers <rgoers@nextiva.com <ma...@nextiva.com>>
>>> Committed: Sun Jan 24 11:18:41 2016 -0700
>>> 
>>> ----------------------------------------------------------------------
>>>  .../org/apache/logging/log4j/LogManager.java    | 62 ++++++++++++++++++++
>>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>>  4 files changed, 93 insertions(+), 1 deletion(-)
>>> ----------------------------------------------------------------------
>>> 
>>> 
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java>
>>> ----------------------------------------------------------------------
>>> diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> index f10e5a8..64c6ee5 100644
>>> --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> @@ -27,6 +27,7 @@ import org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>>  import org.apache.logging.log4j.spi.LoggerContext;
>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>  import org.apache.logging.log4j.spi.Provider;
>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>  import org.apache.logging.log4j.status.StatusLogger;
>>>  import org.apache.logging.log4j.util.LoaderUtil;
>>>  import org.apache.logging.log4j.util.PropertiesUtil;
>>> @@ -285,6 +286,67 @@ public class LogManager {
>>>      }
>>> 
>>>      /**
>>> +     * Shutdown using the default LoggerContext.
>>> +     * @since 2.6
>>> +     */
>>> +    public static void shutdown() {
>>> +        shutdown(getContext());
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param currentContext if true the LoggerContext for the caller of this method will be used.
>>> +     * @since 2.6
>>> +     */
>>> +    public static void shutdown(boolean currentContext) {
>>> +        shutdown(getContext(currentContext));
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param loader The ClassLoader for the context. If null the context will attempt to determine the appropriate
>>> +     *            ClassLoader.
>>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>>> +     * @since 2.6
>>> +     */
>>> +    public static void shutdown(final ClassLoader loader, final boolean currentContext) {
>>> +        shutdown(getContext(loader, currentContext));
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param context the LoggerContext.
>>> +     * @since 2.6
>>> +     */
>>> +    public static void shutdown(LoggerContext context) {
>>> +        if (context != null && context instanceof ShutdownCapable) {
>>> +            ((ShutdownCapable) context).shutdown();
>>> +        }
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param fqcn The fully qualified class name of the Class that this method is a member of.
>>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>>> +     * @since 2.6
>>> +     */
>>> +    protected static void shutdown(final String fqcn, final boolean currentContext) {
>>> +        shutdown(getContext(fqcn, currentContext));
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param fqcn The fully qualified class name of the Class that this method is a member of.
>>> +     * @param loader The ClassLoader for the context. If null the context will attempt to determine the appropriate
>>> +     *            ClassLoader.
>>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>>> +     * @since 2.6
>>> +     */
>>> +    protected static void shutdown(final String fqcn, final ClassLoader loader, final boolean currentContext) {
>>> +        shutdown(getContext(fqcn, loader, currentContext));
>>> +    }
>>> +
>>> +    /**
>>>       * Returns the current LoggerContextFactory.
>>>       *
>>>       * @return The LoggerContextFactory.
>>> 
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java>
>>> ----------------------------------------------------------------------
>>> diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>> new file mode 100644
>>> index 0000000..a46ef60
>>> --- /dev/null
>>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>> @@ -0,0 +1,17 @@
>>> +/*
>>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>>> + * All rights reserved.
>>> + */
>>> +package org.apache.logging.log4j.spi;
>>> +
>>> +/**
>>> + * Interface to be implemented by LoggerContext's that provide a shutdown method.
>>> + * @since 2.6
>>> + */
>>> +public interface ShutdownCapable {
>>> +
>>> +    /**
>>> +     * Requests that the logging implementation shut down.
>>> +     */
>>> +    void shutdown();
>>> +}
>>> 
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java>
>>> ----------------------------------------------------------------------
>>> diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> index 48f0eea..596a9f2 100644
>>> --- a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> +++ b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> @@ -17,6 +17,7 @@
>>>  package org.apache.logging.log4j;
>>> 
>>>  import org.apache.logging.log4j.message.ParameterizedMessageFactory;
>>> +import org.apache.logging.log4j.spi.LoggerContext;
>>>  import org.junit.Test;
>>> 
>>>  import static org.junit.Assert.*;
>>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>>          assertNotNull("No Logger returned", logger);
>>>          assertTrue("Incorrect Logger name: " + logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>>      }
>>> +
>>> +    @Test
>>> +    public void testShutdown() {
>>> +        LoggerContext loggerContext = LogManager.getContext(false);
>>> +        LogManager.shutdown(loggerContext);
>>> +    }
>>>  }
>>> 
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java>
>>> ----------------------------------------------------------------------
>>> diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> index 42efbb5..fcdfc16 100644
>>> --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> @@ -45,6 +45,7 @@ import org.apache.logging.log4j.message.MessageFactory;
>>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>> 
>>>  import static org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>> 
>>> @@ -54,7 +55,7 @@ import static org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>   * filters, etc and will be atomically updated whenever a reconfigure occurs.
>>>   */
>>>  public class LoggerContext extends AbstractLifeCycle implements org.apache.logging.log4j.spi.LoggerContext,
>>> -        ConfigurationListener {
>>> +        ShutdownCapable, ConfigurationListener {
>>> 
>>>      /**
>>>       * Property name of the property change event fired if the configuration is changed.
>>> @@ -278,6 +279,11 @@ public class LoggerContext extends AbstractLifeCycle implements org.apache.loggi
>>>      }
>>> 
>>>      @Override
>>> +    public void shutdown() {
>>> +        stop();
>>> +    }
>>> +
>>> +    @Override
>>>      public void stop() {
>>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...", getName(), this);
>>>          configLock.lock();
>>> 
>> 
>> 
>> 
>> 
>> -- 
>> E-Mail: garydgregory@gmail.com <ma...@gmail.com> | ggregory@apache.org  <ma...@apache.org>
>> Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> 
>> Home: http://garygregory.com/ <http://garygregory.com/>
>> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>
>> 
>> 
>> -- 
>> E-Mail: garydgregory@gmail.com <ma...@gmail.com> | ggregory@apache.org  <ma...@apache.org>
>> Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> 
>> Home: http://garygregory.com/ <http://garygregory.com/>
>> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>
> 
> 
> 
> -- 
> E-Mail: garydgregory@gmail.com <ma...@gmail.com> | ggregory@apache.org  <ma...@apache.org>
> Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> 
> Home: http://garygregory.com/ <http://garygregory.com/>
> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>
> 
> 
> -- 
> Matt Sicker <boards@gmail.com <ma...@gmail.com>>
> 


Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Guido Medina <ox...@gmail.com>.
Due to current implementation I think start lazy shouldn't be changed or
else you will introduce another life-cycle mayhem, instead add a
configuration property to enable/disable shutdown hook and add stop method:

I have micro-services in Akka for example with ActorSystem.shutdown under a
JVM shutdown hook and sometimes Log4j2 stops before Akka, in that scenario
I would like to disable Log4j2 shutdown hook and call stop myself.

Hope that makes sense,

Guido.

On Tue, Jan 26, 2016 at 12:00 AM, Matt Sicker <bo...@gmail.com> wrote:

> Lifecycle/LifeCycle is the closest thing I see already in log4j and
> Spring. Camel has an interface called ShutdownableService which is similar
> (but extends their Service interface).
>
> Other projects:
> * CXF uses the Bus interface which has a shutdown method.
> * OSGi has Bundle.stop() which is rather similar to a generic Lifecycle
> interface overall
> * Hadoop has a Service interface with a stop() method
> * Tomcat as a Lifecycle interface with a stop() method
>
> I mean the basic idea I'm seeing here is that nobody seems to make a class
> with a stop-style method without an accompanying start-style method.
>
> On 25 January 2016 at 17:35, Gary Gregory <ga...@gmail.com> wrote:
>
>> I see some interfaces with "*Capable*" in the name here and there in the
>> FOSS world (but not in the JRE) so I am a little more comfortable with it.
>>
>> I still see plain old "Shutdown" as simpler.
>>
>> I think I've boiled down my feel for this name to the fact that the
>> Capable postfix is redundant since a class implementing any interface is
>> "capable" of that functionality. IOW we have Serializable vs.
>> SerializationCabable, which means the same thing.
>>
>> Gary
>>
>> On Mon, Jan 25, 2016 at 7:27 AM, Ralph Goers <ra...@dslextreme.com>
>> wrote:
>>
>>> What does it feel weird to you?  To be honest, I originally named the
>>> interface ‘Shutdown” and then changed it since it really is about
>>> implementing a behavior and “Shutdown” alone doesn’t really describe that.
>>>
>>> Ralph
>>>
>>> On Jan 24, 2016, at 11:09 PM, Gary Gregory <ga...@gmail.com>
>>> wrote:
>>>
>>> On Sun, Jan 24, 2016 at 10:07 PM, Gary Gregory <ga...@gmail.com>
>>> wrote:
>>>
>>>> On Sun, Jan 24, 2016 at 1:54 PM, Ralph Goers <
>>>> ralph.goers@dslextreme.com> wrote:
>>>>
>>>>> Yes, Shutdownable is too weird.
>>>>>
>>>>
>>>> How about calling it simply "Shutdown" then? FooCapable feels weird to
>>>> me.
>>>>
>>>> Can anyone think of other (one-method or not) optional feature-like
>>>> interfaces in the JRE or other code base?
>>>>
>>>
>>> hm... ShutdownService?
>>>
>>> Gary
>>>
>>>
>>>>
>>>> Gary
>>>>
>>>> Closeable would imply there is a close method, not a shutdown method.
>>>>> I have my doubts about the try-with-resources use case here.  Virtually all
>>>>> usages are probably going to be to disable automatic shutdown and then the
>>>>> user placing the shutdown call somewhere they can control, which probably
>>>>> will have nothing to do with initialization of logging.
>>>>>
>>>>> Ralph
>>>>>
>>>>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <ga...@gmail.com>
>>>>> wrote:
>>>>>
>>>>> Resending, got a error from my phone...
>>>>> ---------- Forwarded message ----------
>>>>> From: "Gary Gregory" <ga...@gmail.com>
>>>>> Date: Jan 24, 2016 1:41 PM
>>>>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown
>>>>> methods to LogManager
>>>>> To: <de...@logging.apache.org>
>>>>> Cc:
>>>>>
>>>>> Hi all,
>>>>>
>>>>> Any reason not use the usual -able postfix instead of ShutdownCapable:
>>>>> Shutdownable sounds too weird? What about reusing plain old Closeable? That
>>>>> means you could use the context in a try-with-resources block, a bonus.
>>>>>
>>>>> Gary
>>>>> On Jan 24, 2016 10:18 AM, <rg...@apache.org> wrote:
>>>>>
>>>>>> Repository: logging-log4j2
>>>>>> Updated Branches:
>>>>>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>>>>>>
>>>>>>
>>>>>> LOG4J2-124 - Add shutdown methods to LogManager
>>>>>>
>>>>>>
>>>>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>>>>> Commit:
>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7
>>>>>> Tree:
>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7
>>>>>> Diff:
>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7
>>>>>>
>>>>>> Branch: refs/heads/master
>>>>>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>>>>>> Parents: 7d3aac4
>>>>>> Author: Ralph Goers <rg...@nextiva.com>
>>>>>> Authored: Sun Jan 24 11:18:41 2016 -0700
>>>>>> Committer: Ralph Goers <rg...@nextiva.com>
>>>>>> Committed: Sun Jan 24 11:18:41 2016 -0700
>>>>>>
>>>>>> ----------------------------------------------------------------------
>>>>>>  .../org/apache/logging/log4j/LogManager.java    | 62
>>>>>> ++++++++++++++++++++
>>>>>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>>>>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>>>>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>>>>>  4 files changed, 93 insertions(+), 1 deletion(-)
>>>>>> ----------------------------------------------------------------------
>>>>>>
>>>>>>
>>>>>>
>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>> ----------------------------------------------------------------------
>>>>>> diff --git
>>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>> index f10e5a8..64c6ee5 100644
>>>>>> --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>> @@ -27,6 +27,7 @@ import
>>>>>> org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>>>>>  import org.apache.logging.log4j.spi.LoggerContext;
>>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>>  import org.apache.logging.log4j.spi.Provider;
>>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>>  import org.apache.logging.log4j.status.StatusLogger;
>>>>>>  import org.apache.logging.log4j.util.LoaderUtil;
>>>>>>  import org.apache.logging.log4j.util.PropertiesUtil;
>>>>>> @@ -285,6 +286,67 @@ public class LogManager {
>>>>>>      }
>>>>>>
>>>>>>      /**
>>>>>> +     * Shutdown using the default LoggerContext.
>>>>>> +     * @since 2.6
>>>>>> +     */
>>>>>> +    public static void shutdown() {
>>>>>> +        shutdown(getContext());
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>>> +     * @param currentContext if true the LoggerContext for the
>>>>>> caller of this method will be used.
>>>>>> +     * @since 2.6
>>>>>> +     */
>>>>>> +    public static void shutdown(boolean currentContext) {
>>>>>> +        shutdown(getContext(currentContext));
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>>> +     * @param loader The ClassLoader for the context. If null the
>>>>>> context will attempt to determine the appropriate
>>>>>> +     *            ClassLoader.
>>>>>> +     * @param currentContext if false the LoggerContext appropriate
>>>>>> for the caller of this method will be used.
>>>>>> +     * @since 2.6
>>>>>> +     */
>>>>>> +    public static void shutdown(final ClassLoader loader, final
>>>>>> boolean currentContext) {
>>>>>> +        shutdown(getContext(loader, currentContext));
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>>> +     * @param context the LoggerContext.
>>>>>> +     * @since 2.6
>>>>>> +     */
>>>>>> +    public static void shutdown(LoggerContext context) {
>>>>>> +        if (context != null && context instanceof ShutdownCapable) {
>>>>>> +            ((ShutdownCapable) context).shutdown();
>>>>>> +        }
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>>> +     * @param fqcn The fully qualified class name of the Class that
>>>>>> this method is a member of.
>>>>>> +     * @param currentContext if false the LoggerContext appropriate
>>>>>> for the caller of this method will be used.
>>>>>> +     * @since 2.6
>>>>>> +     */
>>>>>> +    protected static void shutdown(final String fqcn, final boolean
>>>>>> currentContext) {
>>>>>> +        shutdown(getContext(fqcn, currentContext));
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>>> +     * @param fqcn The fully qualified class name of the Class that
>>>>>> this method is a member of.
>>>>>> +     * @param loader The ClassLoader for the context. If null the
>>>>>> context will attempt to determine the appropriate
>>>>>> +     *            ClassLoader.
>>>>>> +     * @param currentContext if false the LoggerContext appropriate
>>>>>> for the caller of this method will be used.
>>>>>> +     * @since 2.6
>>>>>> +     */
>>>>>> +    protected static void shutdown(final String fqcn, final
>>>>>> ClassLoader loader, final boolean currentContext) {
>>>>>> +        shutdown(getContext(fqcn, loader, currentContext));
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>>       * Returns the current LoggerContextFactory.
>>>>>>       *
>>>>>>       * @return The LoggerContextFactory.
>>>>>>
>>>>>>
>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>> ----------------------------------------------------------------------
>>>>>> diff --git
>>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>> new file mode 100644
>>>>>> index 0000000..a46ef60
>>>>>> --- /dev/null
>>>>>> +++
>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>> @@ -0,0 +1,17 @@
>>>>>> +/*
>>>>>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>>>>>> + * All rights reserved.
>>>>>> + */
>>>>>> +package org.apache.logging.log4j.spi;
>>>>>> +
>>>>>> +/**
>>>>>> + * Interface to be implemented by LoggerContext's that provide a
>>>>>> shutdown method.
>>>>>> + * @since 2.6
>>>>>> + */
>>>>>> +public interface ShutdownCapable {
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Requests that the logging implementation shut down.
>>>>>> +     */
>>>>>> +    void shutdown();
>>>>>> +}
>>>>>>
>>>>>>
>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>> ----------------------------------------------------------------------
>>>>>> diff --git
>>>>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>> index 48f0eea..596a9f2 100644
>>>>>> ---
>>>>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>> +++
>>>>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>> @@ -17,6 +17,7 @@
>>>>>>  package org.apache.logging.log4j;
>>>>>>
>>>>>>  import org.apache.logging.log4j.message.ParameterizedMessageFactory;
>>>>>> +import org.apache.logging.log4j.spi.LoggerContext;
>>>>>>  import org.junit.Test;
>>>>>>
>>>>>>  import static org.junit.Assert.*;
>>>>>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>>>>>          assertNotNull("No Logger returned", logger);
>>>>>>          assertTrue("Incorrect Logger name: " +
>>>>>> logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>>>>>      }
>>>>>> +
>>>>>> +    @Test
>>>>>> +    public void testShutdown() {
>>>>>> +        LoggerContext loggerContext = LogManager.getContext(false);
>>>>>> +        LogManager.shutdown(loggerContext);
>>>>>> +    }
>>>>>>  }
>>>>>>
>>>>>>
>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>> ----------------------------------------------------------------------
>>>>>> diff --git
>>>>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>> index 42efbb5..fcdfc16 100644
>>>>>> ---
>>>>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>> +++
>>>>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>> @@ -45,6 +45,7 @@ import
>>>>>> org.apache.logging.log4j.message.MessageFactory;
>>>>>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>>
>>>>>>  import static
>>>>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>>
>>>>>> @@ -54,7 +55,7 @@ import static
>>>>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>>   * filters, etc and will be atomically updated whenever a
>>>>>> reconfigure occurs.
>>>>>>   */
>>>>>>  public class LoggerContext extends AbstractLifeCycle implements
>>>>>> org.apache.logging.log4j.spi.LoggerContext,
>>>>>> -        ConfigurationListener {
>>>>>> +        ShutdownCapable, ConfigurationListener {
>>>>>>
>>>>>>      /**
>>>>>>       * Property name of the property change event fired if the
>>>>>> configuration is changed.
>>>>>> @@ -278,6 +279,11 @@ public class LoggerContext extends
>>>>>> AbstractLifeCycle implements org.apache.loggi
>>>>>>      }
>>>>>>
>>>>>>      @Override
>>>>>> +    public void shutdown() {
>>>>>> +        stop();
>>>>>> +    }
>>>>>> +
>>>>>> +    @Override
>>>>>>      public void stop() {
>>>>>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...",
>>>>>> getName(), this);
>>>>>>          configLock.lock();
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>> <gg...@apache.org>
>>>> Java Persistence with Hibernate, Second Edition
>>>> <http://www.manning.com/bauer3/>
>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>> Blog: http://garygregory.wordpress.com
>>>> Home: http://garygregory.com/
>>>> Tweet! http://twitter.com/GaryGregory
>>>>
>>>
>>>
>>>
>>> --
>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>> <gg...@apache.org>
>>> Java Persistence with Hibernate, Second Edition
>>> <http://www.manning.com/bauer3/>
>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>> Spring Batch in Action <http://www.manning.com/templier/>
>>> Blog: http://garygregory.wordpress.com
>>> Home: http://garygregory.com/
>>> Tweet! http://twitter.com/GaryGregory
>>>
>>>
>>>
>>
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> Java Persistence with Hibernate, Second Edition
>> <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
>>
>
>
>
> --
> Matt Sicker <bo...@gmail.com>
>

Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Matt Sicker <bo...@gmail.com>.
Lifecycle/LifeCycle is the closest thing I see already in log4j and Spring.
Camel has an interface called ShutdownableService which is similar (but
extends their Service interface).

Other projects:
* CXF uses the Bus interface which has a shutdown method.
* OSGi has Bundle.stop() which is rather similar to a generic Lifecycle
interface overall
* Hadoop has a Service interface with a stop() method
* Tomcat as a Lifecycle interface with a stop() method

I mean the basic idea I'm seeing here is that nobody seems to make a class
with a stop-style method without an accompanying start-style method.

On 25 January 2016 at 17:35, Gary Gregory <ga...@gmail.com> wrote:

> I see some interfaces with "*Capable*" in the name here and there in the
> FOSS world (but not in the JRE) so I am a little more comfortable with it.
>
> I still see plain old "Shutdown" as simpler.
>
> I think I've boiled down my feel for this name to the fact that the
> Capable postfix is redundant since a class implementing any interface is
> "capable" of that functionality. IOW we have Serializable vs.
> SerializationCabable, which means the same thing.
>
> Gary
>
> On Mon, Jan 25, 2016 at 7:27 AM, Ralph Goers <ra...@dslextreme.com>
> wrote:
>
>> What does it feel weird to you?  To be honest, I originally named the
>> interface ‘Shutdown” and then changed it since it really is about
>> implementing a behavior and “Shutdown” alone doesn’t really describe that.
>>
>> Ralph
>>
>> On Jan 24, 2016, at 11:09 PM, Gary Gregory <ga...@gmail.com>
>> wrote:
>>
>> On Sun, Jan 24, 2016 at 10:07 PM, Gary Gregory <ga...@gmail.com>
>> wrote:
>>
>>> On Sun, Jan 24, 2016 at 1:54 PM, Ralph Goers <ralph.goers@dslextreme.com
>>> > wrote:
>>>
>>>> Yes, Shutdownable is too weird.
>>>>
>>>
>>> How about calling it simply "Shutdown" then? FooCapable feels weird to
>>> me.
>>>
>>> Can anyone think of other (one-method or not) optional feature-like
>>> interfaces in the JRE or other code base?
>>>
>>
>> hm... ShutdownService?
>>
>> Gary
>>
>>
>>>
>>> Gary
>>>
>>> Closeable would imply there is a close method, not a shutdown method.  I
>>>> have my doubts about the try-with-resources use case here.  Virtually all
>>>> usages are probably going to be to disable automatic shutdown and then the
>>>> user placing the shutdown call somewhere they can control, which probably
>>>> will have nothing to do with initialization of logging.
>>>>
>>>> Ralph
>>>>
>>>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <ga...@gmail.com>
>>>> wrote:
>>>>
>>>> Resending, got a error from my phone...
>>>> ---------- Forwarded message ----------
>>>> From: "Gary Gregory" <ga...@gmail.com>
>>>> Date: Jan 24, 2016 1:41 PM
>>>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown
>>>> methods to LogManager
>>>> To: <de...@logging.apache.org>
>>>> Cc:
>>>>
>>>> Hi all,
>>>>
>>>> Any reason not use the usual -able postfix instead of ShutdownCapable:
>>>> Shutdownable sounds too weird? What about reusing plain old Closeable? That
>>>> means you could use the context in a try-with-resources block, a bonus.
>>>>
>>>> Gary
>>>> On Jan 24, 2016 10:18 AM, <rg...@apache.org> wrote:
>>>>
>>>>> Repository: logging-log4j2
>>>>> Updated Branches:
>>>>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>>>>>
>>>>>
>>>>> LOG4J2-124 - Add shutdown methods to LogManager
>>>>>
>>>>>
>>>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>>>> Commit:
>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7
>>>>> Tree:
>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7
>>>>> Diff:
>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7
>>>>>
>>>>> Branch: refs/heads/master
>>>>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>>>>> Parents: 7d3aac4
>>>>> Author: Ralph Goers <rg...@nextiva.com>
>>>>> Authored: Sun Jan 24 11:18:41 2016 -0700
>>>>> Committer: Ralph Goers <rg...@nextiva.com>
>>>>> Committed: Sun Jan 24 11:18:41 2016 -0700
>>>>>
>>>>> ----------------------------------------------------------------------
>>>>>  .../org/apache/logging/log4j/LogManager.java    | 62
>>>>> ++++++++++++++++++++
>>>>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>>>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>>>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>>>>  4 files changed, 93 insertions(+), 1 deletion(-)
>>>>> ----------------------------------------------------------------------
>>>>>
>>>>>
>>>>>
>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>> ----------------------------------------------------------------------
>>>>> diff --git
>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>> index f10e5a8..64c6ee5 100644
>>>>> --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>> @@ -27,6 +27,7 @@ import
>>>>> org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>>>>  import org.apache.logging.log4j.spi.LoggerContext;
>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>  import org.apache.logging.log4j.spi.Provider;
>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>  import org.apache.logging.log4j.status.StatusLogger;
>>>>>  import org.apache.logging.log4j.util.LoaderUtil;
>>>>>  import org.apache.logging.log4j.util.PropertiesUtil;
>>>>> @@ -285,6 +286,67 @@ public class LogManager {
>>>>>      }
>>>>>
>>>>>      /**
>>>>> +     * Shutdown using the default LoggerContext.
>>>>> +     * @since 2.6
>>>>> +     */
>>>>> +    public static void shutdown() {
>>>>> +        shutdown(getContext());
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>> +     * @param currentContext if true the LoggerContext for the caller
>>>>> of this method will be used.
>>>>> +     * @since 2.6
>>>>> +     */
>>>>> +    public static void shutdown(boolean currentContext) {
>>>>> +        shutdown(getContext(currentContext));
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>> +     * @param loader The ClassLoader for the context. If null the
>>>>> context will attempt to determine the appropriate
>>>>> +     *            ClassLoader.
>>>>> +     * @param currentContext if false the LoggerContext appropriate
>>>>> for the caller of this method will be used.
>>>>> +     * @since 2.6
>>>>> +     */
>>>>> +    public static void shutdown(final ClassLoader loader, final
>>>>> boolean currentContext) {
>>>>> +        shutdown(getContext(loader, currentContext));
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>> +     * @param context the LoggerContext.
>>>>> +     * @since 2.6
>>>>> +     */
>>>>> +    public static void shutdown(LoggerContext context) {
>>>>> +        if (context != null && context instanceof ShutdownCapable) {
>>>>> +            ((ShutdownCapable) context).shutdown();
>>>>> +        }
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>> +     * @param fqcn The fully qualified class name of the Class that
>>>>> this method is a member of.
>>>>> +     * @param currentContext if false the LoggerContext appropriate
>>>>> for the caller of this method will be used.
>>>>> +     * @since 2.6
>>>>> +     */
>>>>> +    protected static void shutdown(final String fqcn, final boolean
>>>>> currentContext) {
>>>>> +        shutdown(getContext(fqcn, currentContext));
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>> +     * @param fqcn The fully qualified class name of the Class that
>>>>> this method is a member of.
>>>>> +     * @param loader The ClassLoader for the context. If null the
>>>>> context will attempt to determine the appropriate
>>>>> +     *            ClassLoader.
>>>>> +     * @param currentContext if false the LoggerContext appropriate
>>>>> for the caller of this method will be used.
>>>>> +     * @since 2.6
>>>>> +     */
>>>>> +    protected static void shutdown(final String fqcn, final
>>>>> ClassLoader loader, final boolean currentContext) {
>>>>> +        shutdown(getContext(fqcn, loader, currentContext));
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>>       * Returns the current LoggerContextFactory.
>>>>>       *
>>>>>       * @return The LoggerContextFactory.
>>>>>
>>>>>
>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>> ----------------------------------------------------------------------
>>>>> diff --git
>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>> new file mode 100644
>>>>> index 0000000..a46ef60
>>>>> --- /dev/null
>>>>> +++
>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>> @@ -0,0 +1,17 @@
>>>>> +/*
>>>>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>>>>> + * All rights reserved.
>>>>> + */
>>>>> +package org.apache.logging.log4j.spi;
>>>>> +
>>>>> +/**
>>>>> + * Interface to be implemented by LoggerContext's that provide a
>>>>> shutdown method.
>>>>> + * @since 2.6
>>>>> + */
>>>>> +public interface ShutdownCapable {
>>>>> +
>>>>> +    /**
>>>>> +     * Requests that the logging implementation shut down.
>>>>> +     */
>>>>> +    void shutdown();
>>>>> +}
>>>>>
>>>>>
>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>> ----------------------------------------------------------------------
>>>>> diff --git
>>>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>> index 48f0eea..596a9f2 100644
>>>>> ---
>>>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>> +++
>>>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>> @@ -17,6 +17,7 @@
>>>>>  package org.apache.logging.log4j;
>>>>>
>>>>>  import org.apache.logging.log4j.message.ParameterizedMessageFactory;
>>>>> +import org.apache.logging.log4j.spi.LoggerContext;
>>>>>  import org.junit.Test;
>>>>>
>>>>>  import static org.junit.Assert.*;
>>>>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>>>>          assertNotNull("No Logger returned", logger);
>>>>>          assertTrue("Incorrect Logger name: " +
>>>>> logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>>>>      }
>>>>> +
>>>>> +    @Test
>>>>> +    public void testShutdown() {
>>>>> +        LoggerContext loggerContext = LogManager.getContext(false);
>>>>> +        LogManager.shutdown(loggerContext);
>>>>> +    }
>>>>>  }
>>>>>
>>>>>
>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>> ----------------------------------------------------------------------
>>>>> diff --git
>>>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>> index 42efbb5..fcdfc16 100644
>>>>> ---
>>>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>> +++
>>>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>> @@ -45,6 +45,7 @@ import
>>>>> org.apache.logging.log4j.message.MessageFactory;
>>>>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>
>>>>>  import static
>>>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>
>>>>> @@ -54,7 +55,7 @@ import static
>>>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>   * filters, etc and will be atomically updated whenever a
>>>>> reconfigure occurs.
>>>>>   */
>>>>>  public class LoggerContext extends AbstractLifeCycle implements
>>>>> org.apache.logging.log4j.spi.LoggerContext,
>>>>> -        ConfigurationListener {
>>>>> +        ShutdownCapable, ConfigurationListener {
>>>>>
>>>>>      /**
>>>>>       * Property name of the property change event fired if the
>>>>> configuration is changed.
>>>>> @@ -278,6 +279,11 @@ public class LoggerContext extends
>>>>> AbstractLifeCycle implements org.apache.loggi
>>>>>      }
>>>>>
>>>>>      @Override
>>>>> +    public void shutdown() {
>>>>> +        stop();
>>>>> +    }
>>>>> +
>>>>> +    @Override
>>>>>      public void stop() {
>>>>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...",
>>>>> getName(), this);
>>>>>          configLock.lock();
>>>>>
>>>>>
>>>>
>>>
>>>
>>> --
>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>> <gg...@apache.org>
>>> Java Persistence with Hibernate, Second Edition
>>> <http://www.manning.com/bauer3/>
>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>> Spring Batch in Action <http://www.manning.com/templier/>
>>> Blog: http://garygregory.wordpress.com
>>> Home: http://garygregory.com/
>>> Tweet! http://twitter.com/GaryGregory
>>>
>>
>>
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> <gg...@apache.org>
>> Java Persistence with Hibernate, Second Edition
>> <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
>>
>>
>>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
Matt Sicker <bo...@gmail.com>

Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Remko Popma <re...@gmail.com>.
Nice!

Sent from my iPhone

> On 2016/01/27, at 22:27, Mikael Ståldal <mi...@magine.com> wrote:
> 
> OK, also done.
> 
>> On Wed, Jan 27, 2016 at 2:07 PM, Remko Popma <re...@gmail.com> wrote:
>> Perhaps you also want to add this to the LogManager.shutdown() methods, since I imagine that's what people will actually use/look at. 
>> 
>> Sent from my iPhone
>> 
>>> On 2016/01/27, at 18:20, Mikael Ståldal <mi...@magine.com> wrote:
>>> 
>>> OK, done.
>>> 
>>>> On Wed, Jan 27, 2016 at 6:17 AM, Remko Popma <re...@gmail.com> wrote:
>>>> Mikael, feel free to update the javadoc when you have time. 
>>>> 
>>>> 
>>>>> On Wednesday, 27 January 2016, Remko Popma <re...@gmail.com> wrote:
>>>>> Since the async loggers and appenders will wait until their queue has been cleared by the background thread, it is a blocking call. 
>>>>> 
>>>>> We should probably add a sentence to the java doc to clarify this.  
>>>>> 
>>>>> Sent from my iPhone
>>>>> 
>>>>>> On 2016/01/26, at 18:15, Mikael Ståldal <mi...@magine.com> wrote:
>>>>>> 
>>>>>> I think that we should be clear, in Javadoc, about whether this new method is synchronous/blocking or not.
>>>>>> 
>>>>>> (I could say the same about quite a few existing methods as well, but let's at least start to be clear about new methods from now.)
>>>>>> 
>>>>>>> On Tue, Jan 26, 2016 at 1:31 AM, Matt Sicker <bo...@gmail.com> wrote:
>>>>>>> I like it!
>>>>>>> 
>>>>>>>> On 25 January 2016 at 18:23, Ralph Goers <ra...@dslextreme.com> wrote:
>>>>>>>> Then the method name would be terminate?  I could live with that.  I also like the fact that when something goes wrong with it then it would be interminable ;-)
>>>>>>>> 
>>>>>>>> Ralph
>>>>>>>> 
>>>>>>>>> On Jan 25, 2016, at 5:18 PM, Matt Sicker <bo...@gmail.com> wrote:
>>>>>>>>> 
>>>>>>>>> How about Terminable? It's even a real word to boot.
>>>>>>>>> 
>>>>>>>>> On 25 January 2016 at 18:15, Ralph Goers <ra...@dslextreme.com> wrote:
>>>>>>>>>> Yes, well - Serializable actually sounds like it should be a real word. Shutdownable doesn’t - in fact, my mail editor just split it into two words to “help” me. I take a different view. A class that declares it implements an interface isn’t “capable” of anything - it just implements the interface. The interface name is what tells you that the implementing class is able to do something, which is why you have Comparable instead of just Compare, Cloneable instead of just Clone,  or Closeable instead of just Close. Would you want Stop instead of Stoppable?  I view “able” as just a shorthand way of saying “Capable”, but unfortunately that just doesn’t sound right with Shutdown (at least to me).
>>>>>>>>>> 
>>>>>>>>>> Here are some “able” alternatives - presumably each would have a corresponding method name instead of shutdown:
>>>>>>>>>> Terminateable.
>>>>>>>>>> Completeable.
>>>>>>>>>> Concludeable.
>>>>>>>>>> Haltable.
>>>>>>>>>> Dismissable.
>>>>>>>>>> Expireable.
>>>>>>>>>> 
>>>>>>>>>> I suppose we could also use Stoppable but that seems odd since stop is part of Lifecycle.
>>>>>>>>>> 
>>>>>>>>>> Got a preference?
>>>>>>>>>> 
>>>>>>>>>> Ralph
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>>> On Jan 25, 2016, at 4:35 PM, Gary Gregory <ga...@gmail.com> wrote:
>>>>>>>>>>> 
>>>>>>>>>>> I see some interfaces with "*Capable*" in the name here and there in the FOSS world (but not in the JRE) so I am a little more comfortable with it. 
>>>>>>>>>>> 
>>>>>>>>>>> I still see plain old "Shutdown" as simpler. 
>>>>>>>>>>> 
>>>>>>>>>>> I think I've boiled down my feel for this name to the fact that the Capable postfix is redundant since a class implementing any interface is "capable" of that functionality. IOW we have Serializable vs. SerializationCabable, which means the same thing.
>>>>>>>>>>> 
>>>>>>>>>>> Gary
>>>>>>>>>>> 
>>>>>>>>>>>> On Mon, Jan 25, 2016 at 7:27 AM, Ralph Goers <ra...@dslextreme.com> wrote:
>>>>>>>>>>>> What does it feel weird to you?  To be honest, I originally named the interface ‘Shutdown” and then changed it since it really is about implementing a behavior and “Shutdown” alone doesn’t really describe that.
>>>>>>>>>>>> 
>>>>>>>>>>>> Ralph
>>>>>>>>>>>> 
>>>>>>>>>>>>> On Jan 24, 2016, at 11:09 PM, Gary Gregory <ga...@gmail.com> wrote:
>>>>>>>>>>>>> 
>>>>>>>>>>>>>> On Sun, Jan 24, 2016 at 10:07 PM, Gary Gregory <ga...@gmail.com> wrote:
>>>>>>>>>>>>>>> On Sun, Jan 24, 2016 at 1:54 PM, Ralph Goers <ra...@dslextreme.com> wrote:
>>>>>>>>>>>>>>> Yes, Shutdownable is too weird. 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> How about calling it simply "Shutdown" then? FooCapable feels weird to me.
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Can anyone think of other (one-method or not) optional feature-like interfaces in the JRE or other code base?
>>>>>>>>>>>>> 
>>>>>>>>>>>>> hm... ShutdownService?
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Gary
>>>>>>>>>>>>>  
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Gary
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> Closeable would imply there is a close method, not a shutdown method.  I have my doubts about the try-with-resources use case here.  Virtually all usages are probably going to be to disable automatic shutdown and then the user placing the shutdown call somewhere they can control, which probably will have nothing to do with initialization of logging. 
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> Ralph
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <ga...@gmail.com> wrote:
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> Resending, got a error from my phone...
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> ---------- Forwarded message ----------
>>>>>>>>>>>>>>>> From: "Gary Gregory" <ga...@gmail.com>
>>>>>>>>>>>>>>>> Date: Jan 24, 2016 1:41 PM
>>>>>>>>>>>>>>>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager
>>>>>>>>>>>>>>>> To: <de...@logging.apache.org>
>>>>>>>>>>>>>>>> Cc: 
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> Hi all,
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> Any reason not use the usual -able postfix instead of ShutdownCapable: Shutdownable sounds too weird? What about reusing plain old Closeable? That means you could use the context in a try-with-resources block, a bonus.
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> Gary 
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> On Jan 24, 2016 10:18 AM, <rg...@apache.org> wrote:
>>>>>>>>>>>>>>>>> Repository: logging-log4j2
>>>>>>>>>>>>>>>>> Updated Branches:
>>>>>>>>>>>>>>>>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> LOG4J2-124 - Add shutdown methods to LogManager
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>>>>>>>>>>>>>>>> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7
>>>>>>>>>>>>>>>>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7
>>>>>>>>>>>>>>>>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> Branch: refs/heads/master
>>>>>>>>>>>>>>>>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>>>>>>>>>>>>>>>>> Parents: 7d3aac4
>>>>>>>>>>>>>>>>> Author: Ralph Goers <rg...@nextiva.com>
>>>>>>>>>>>>>>>>> Authored: Sun Jan 24 11:18:41 2016 -0700
>>>>>>>>>>>>>>>>> Committer: Ralph Goers <rg...@nextiva.com>
>>>>>>>>>>>>>>>>> Committed: Sun Jan 24 11:18:41 2016 -0700
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>>>>>>  .../org/apache/logging/log4j/LogManager.java    | 62 ++++++++++++++++++++
>>>>>>>>>>>>>>>>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>>>>>>>>>>>>>>>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>>>>>>>>>>>>>>>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>>>>>>>>>>>>>>>>  4 files changed, 93 insertions(+), 1 deletion(-)
>>>>>>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>>>>>> diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>>>>>>>>>> index f10e5a8..64c6ee5 100644
>>>>>>>>>>>>>>>>> --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>>>>>>>>>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>>>>>>>>>> @@ -27,6 +27,7 @@ import org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>>>>>>>>>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContext;
>>>>>>>>>>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>>>>>>>>>>>>>  import org.apache.logging.log4j.spi.Provider;
>>>>>>>>>>>>>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>>>>>>>>>>>>>  import org.apache.logging.log4j.status.StatusLogger;
>>>>>>>>>>>>>>>>>  import org.apache.logging.log4j.util.LoaderUtil;
>>>>>>>>>>>>>>>>>  import org.apache.logging.log4j.util.PropertiesUtil;
>>>>>>>>>>>>>>>>> @@ -285,6 +286,67 @@ public class LogManager {
>>>>>>>>>>>>>>>>>      }
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>      /**
>>>>>>>>>>>>>>>>> +     * Shutdown using the default LoggerContext.
>>>>>>>>>>>>>>>>> +     * @since 2.6
>>>>>>>>>>>>>>>>> +     */
>>>>>>>>>>>>>>>>> +    public static void shutdown() {
>>>>>>>>>>>>>>>>> +        shutdown(getContext());
>>>>>>>>>>>>>>>>> +    }
>>>>>>>>>>>>>>>>> +
>>>>>>>>>>>>>>>>> +    /**
>>>>>>>>>>>>>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>>>>>>>>>>>>>> +     * @param currentContext if true the LoggerContext for the caller of this method will be used.
>>>>>>>>>>>>>>>>> +     * @since 2.6
>>>>>>>>>>>>>>>>> +     */
>>>>>>>>>>>>>>>>> +    public static void shutdown(boolean currentContext) {
>>>>>>>>>>>>>>>>> +        shutdown(getContext(currentContext));
>>>>>>>>>>>>>>>>> +    }
>>>>>>>>>>>>>>>>> +
>>>>>>>>>>>>>>>>> +    /**
>>>>>>>>>>>>>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>>>>>>>>>>>>>> +     * @param loader The ClassLoader for the context. If null the context will attempt to determine the appropriate
>>>>>>>>>>>>>>>>> +     *            ClassLoader.
>>>>>>>>>>>>>>>>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>>>>>>>>>>>>>>>>> +     * @since 2.6
>>>>>>>>>>>>>>>>> +     */
>>>>>>>>>>>>>>>>> +    public static void shutdown(final ClassLoader loader, final boolean currentContext) {
>>>>>>>>>>>>>>>>> +        shutdown(getContext(loader, currentContext));
>>>>>>>>>>>>>>>>> +    }
>>>>>>>>>>>>>>>>> +
>>>>>>>>>>>>>>>>> +    /**
>>>>>>>>>>>>>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>>>>>>>>>>>>>> +     * @param context the LoggerContext.
>>>>>>>>>>>>>>>>> +     * @since 2.6
>>>>>>>>>>>>>>>>> +     */
>>>>>>>>>>>>>>>>> +    public static void shutdown(LoggerContext context) {
>>>>>>>>>>>>>>>>> +        if (context != null && context instanceof ShutdownCapable) {
>>>>>>>>>>>>>>>>> +            ((ShutdownCapable) context).shutdown();
>>>>>>>>>>>>>>>>> +        }
>>>>>>>>>>>>>>>>> +    }
>>>>>>>>>>>>>>>>> +
>>>>>>>>>>>>>>>>> +    /**
>>>>>>>>>>>>>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>>>>>>>>>>>>>> +     * @param fqcn The fully qualified class name of the Class that this method is a member of.
>>>>>>>>>>>>>>>>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>>>>>>>>>>>>>>>>> +     * @since 2.6
>>>>>>>>>>>>>>>>> +     */
>>>>>>>>>>>>>>>>> +    protected static void shutdown(final String fqcn, final boolean currentContext) {
>>>>>>>>>>>>>>>>> +        shutdown(getContext(fqcn, currentContext));
>>>>>>>>>>>>>>>>> +    }
>>>>>>>>>>>>>>>>> +
>>>>>>>>>>>>>>>>> +    /**
>>>>>>>>>>>>>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>>>>>>>>>>>>>> +     * @param fqcn The fully qualified class name of the Class that this method is a member of.
>>>>>>>>>>>>>>>>> +     * @param loader The ClassLoader for the context. If null the context will attempt to determine the appropriate
>>>>>>>>>>>>>>>>> +     *            ClassLoader.
>>>>>>>>>>>>>>>>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>>>>>>>>>>>>>>>>> +     * @since 2.6
>>>>>>>>>>>>>>>>> +     */
>>>>>>>>>>>>>>>>> +    protected static void shutdown(final String fqcn, final ClassLoader loader, final boolean currentContext) {
>>>>>>>>>>>>>>>>> +        shutdown(getContext(fqcn, loader, currentContext));
>>>>>>>>>>>>>>>>> +    }
>>>>>>>>>>>>>>>>> +
>>>>>>>>>>>>>>>>> +    /**
>>>>>>>>>>>>>>>>>       * Returns the current LoggerContextFactory.
>>>>>>>>>>>>>>>>>       *
>>>>>>>>>>>>>>>>>       * @return The LoggerContextFactory.
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>>>>>> diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>>>>>>>>>>> new file mode 100644
>>>>>>>>>>>>>>>>> index 0000000..a46ef60
>>>>>>>>>>>>>>>>> --- /dev/null
>>>>>>>>>>>>>>>>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>>>>>>>>>>> @@ -0,0 +1,17 @@
>>>>>>>>>>>>>>>>> +/*
>>>>>>>>>>>>>>>>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>>>>>>>>>>>>>>>>> + * All rights reserved.
>>>>>>>>>>>>>>>>> + */
>>>>>>>>>>>>>>>>> +package org.apache.logging.log4j.spi;
>>>>>>>>>>>>>>>>> +
>>>>>>>>>>>>>>>>> +/**
>>>>>>>>>>>>>>>>> + * Interface to be implemented by LoggerContext's that provide a shutdown method.
>>>>>>>>>>>>>>>>> + * @since 2.6
>>>>>>>>>>>>>>>>> + */
>>>>>>>>>>>>>>>>> +public interface ShutdownCapable {
>>>>>>>>>>>>>>>>> +
>>>>>>>>>>>>>>>>> +    /**
>>>>>>>>>>>>>>>>> +     * Requests that the logging implementation shut down.
>>>>>>>>>>>>>>>>> +     */
>>>>>>>>>>>>>>>>> +    void shutdown();
>>>>>>>>>>>>>>>>> +}
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>>>>>> diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>>>>>>>>>> index 48f0eea..596a9f2 100644
>>>>>>>>>>>>>>>>> --- a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>>>>>>>>>> +++ b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>>>>>>>>>> @@ -17,6 +17,7 @@
>>>>>>>>>>>>>>>>>  package org.apache.logging.log4j;
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>  import org.apache.logging.log4j.message.ParameterizedMessageFactory;
>>>>>>>>>>>>>>>>> +import org.apache.logging.log4j.spi.LoggerContext;
>>>>>>>>>>>>>>>>>  import org.junit.Test;
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>  import static org.junit.Assert.*;
>>>>>>>>>>>>>>>>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>>>>>>>>>>>>>>>>          assertNotNull("No Logger returned", logger);
>>>>>>>>>>>>>>>>>          assertTrue("Incorrect Logger name: " + logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>>>>>>>>>>>>>>>>      }
>>>>>>>>>>>>>>>>> +
>>>>>>>>>>>>>>>>> +    @Test
>>>>>>>>>>>>>>>>> +    public void testShutdown() {
>>>>>>>>>>>>>>>>> +        LoggerContext loggerContext = LogManager.getContext(false);
>>>>>>>>>>>>>>>>> +        LogManager.shutdown(loggerContext);
>>>>>>>>>>>>>>>>> +    }
>>>>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>>>>>> diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>>>>>>>>>> index 42efbb5..fcdfc16 100644
>>>>>>>>>>>>>>>>> --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>>>>>>>>>> +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>>>>>>>>>> @@ -45,6 +45,7 @@ import org.apache.logging.log4j.message.MessageFactory;
>>>>>>>>>>>>>>>>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>>>>>>>>>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>>>>>>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>>>>>>>>>>>>>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>  import static org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> @@ -54,7 +55,7 @@ import static org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>>>>>>>>>>>>>   * filters, etc and will be atomically updated whenever a reconfigure occurs.
>>>>>>>>>>>>>>>>>   */
>>>>>>>>>>>>>>>>>  public class LoggerContext extends AbstractLifeCycle implements org.apache.logging.log4j.spi.LoggerContext,
>>>>>>>>>>>>>>>>> -        ConfigurationListener {
>>>>>>>>>>>>>>>>> +        ShutdownCapable, ConfigurationListener {
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>      /**
>>>>>>>>>>>>>>>>>       * Property name of the property change event fired if the configuration is changed.
>>>>>>>>>>>>>>>>> @@ -278,6 +279,11 @@ public class LoggerContext extends AbstractLifeCycle implements org.apache.loggi
>>>>>>>>>>>>>>>>>      }
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>      @Override
>>>>>>>>>>>>>>>>> +    public void shutdown() {
>>>>>>>>>>>>>>>>> +        stop();
>>>>>>>>>>>>>>>>> +    }
>>>>>>>>>>>>>>>>> +
>>>>>>>>>>>>>>>>> +    @Override
>>>>>>>>>>>>>>>>>      public void stop() {
>>>>>>>>>>>>>>>>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...", getName(), this);
>>>>>>>>>>>>>>>>>          configLock.lock();
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> -- 
>>>>>>>>>>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org 
>>>>>>>>>>>>>> Java Persistence with Hibernate, Second Edition
>>>>>>>>>>>>>> JUnit in Action, Second Edition
>>>>>>>>>>>>>> Spring Batch in Action
>>>>>>>>>>>>>> Blog: http://garygregory.wordpress.com 
>>>>>>>>>>>>>> Home: http://garygregory.com/
>>>>>>>>>>>>>> Tweet! http://twitter.com/GaryGregory
>>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>>>>>>>>> -- 
>>>>>>>>>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org 
>>>>>>>>>>>>> Java Persistence with Hibernate, Second Edition
>>>>>>>>>>>>> JUnit in Action, Second Edition
>>>>>>>>>>>>> Spring Batch in Action
>>>>>>>>>>>>> Blog: http://garygregory.wordpress.com 
>>>>>>>>>>>>> Home: http://garygregory.com/
>>>>>>>>>>>>> Tweet! http://twitter.com/GaryGregory
>>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> -- 
>>>>>>>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org 
>>>>>>>>>>> Java Persistence with Hibernate, Second Edition
>>>>>>>>>>> JUnit in Action, Second Edition
>>>>>>>>>>> Spring Batch in Action
>>>>>>>>>>> Blog: http://garygregory.wordpress.com 
>>>>>>>>>>> Home: http://garygregory.com/
>>>>>>>>>>> Tweet! http://twitter.com/GaryGregory
>>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> -- 
>>>>>>>>> Matt Sicker <bo...@gmail.com>
>>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> -- 
>>>>>>> Matt Sicker <bo...@gmail.com>
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> -- 
>>>>>>  
>>>>>> 
>>>>>> Mikael Ståldal
>>>>>> Senior software developer 
>>>>>> 
>>>>>> Magine TV
>>>>>> mikael.staldal@magine.com    
>>>>>> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com 
>>>>>> 
>>>>>> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
>>>>>> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case, 
>>>>>> you should destroy this message and kindly notify the sender by reply email.   
>>> 
>>> 
>>> 
>>> -- 
>>>  
>>> 
>>> Mikael Ståldal
>>> Senior software developer 
>>> 
>>> Magine TV
>>> mikael.staldal@magine.com    
>>> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com 
>>> 
>>> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
>>> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case, 
>>> you should destroy this message and kindly notify the sender by reply email.   
> 
> 
> 
> -- 
>  
> 
> Mikael Ståldal
> Senior software developer 
> 
> Magine TV
> mikael.staldal@magine.com    
> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com             
> 
> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case, 
> you should destroy this message and kindly notify the sender by reply email.   

Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Mikael Ståldal <mi...@magine.com>.
OK, also done.

On Wed, Jan 27, 2016 at 2:07 PM, Remko Popma <re...@gmail.com> wrote:

> Perhaps you also want to add this to the LogManager.shutdown() methods,
> since I imagine that's what people will actually use/look at.
>
> Sent from my iPhone
>
> On 2016/01/27, at 18:20, Mikael Ståldal <mi...@magine.com> wrote:
>
> OK, done.
>
> On Wed, Jan 27, 2016 at 6:17 AM, Remko Popma <re...@gmail.com>
> wrote:
>
>> Mikael, feel free to update the javadoc when you have time.
>>
>>
>> On Wednesday, 27 January 2016, Remko Popma <re...@gmail.com> wrote:
>>
>>> Since the async loggers and appenders will wait until their queue has
>>> been cleared by the background thread, it is a blocking call.
>>>
>>> We should probably add a sentence to the java doc to clarify this.
>>>
>>> Sent from my iPhone
>>>
>>> On 2016/01/26, at 18:15, Mikael Ståldal <mi...@magine.com>
>>> wrote:
>>>
>>> I think that we should be clear, in Javadoc, about whether this new
>>> method is synchronous/blocking or not.
>>>
>>> (I could say the same about quite a few existing methods as well, but
>>> let's at least start to be clear about new methods from now.)
>>>
>>> On Tue, Jan 26, 2016 at 1:31 AM, Matt Sicker <bo...@gmail.com> wrote:
>>>
>>>> I like it!
>>>>
>>>> On 25 January 2016 at 18:23, Ralph Goers <ra...@dslextreme.com>
>>>> wrote:
>>>>
>>>>> Then the method name would be terminate?  I could live with that.  I
>>>>> also like the fact that when something goes wrong with it then it would be
>>>>> interminable ;-)
>>>>>
>>>>> Ralph
>>>>>
>>>>> On Jan 25, 2016, at 5:18 PM, Matt Sicker <bo...@gmail.com> wrote:
>>>>>
>>>>> How about Terminable? It's even a real word to boot.
>>>>>
>>>>> On 25 January 2016 at 18:15, Ralph Goers <ra...@dslextreme.com>
>>>>> wrote:
>>>>>
>>>>>> Yes, well - Serializable actually sounds like it should be a real
>>>>>> word. Shutdownable doesn’t - in fact, my mail editor just split it into two
>>>>>> words to “help” me. I take a different view. A class that declares it
>>>>>> implements an interface isn’t “capable” of anything - it just implements
>>>>>> the interface. The interface name is what tells you that the implementing
>>>>>> class is able to do something, which is why you have Comparable instead of
>>>>>> just Compare, Cloneable instead of just Clone,  or Closeable instead of
>>>>>> just Close. Would you want Stop instead of Stoppable?  I view “able” as
>>>>>> just a shorthand way of saying “Capable”, but unfortunately that just
>>>>>> doesn’t sound right with Shutdown (at least to me).
>>>>>>
>>>>>> Here are some “able” alternatives - presumably each would have a
>>>>>> corresponding method name instead of shutdown:
>>>>>> Terminateable.
>>>>>> Completeable.
>>>>>> Concludeable.
>>>>>> Haltable.
>>>>>> Dismissable.
>>>>>> Expireable.
>>>>>>
>>>>>> I suppose we could also use Stoppable but that seems odd since stop
>>>>>> is part of Lifecycle.
>>>>>>
>>>>>> Got a preference?
>>>>>>
>>>>>> Ralph
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Jan 25, 2016, at 4:35 PM, Gary Gregory <ga...@gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>> I see some interfaces with "*Capable*" in the name here and there in
>>>>>> the FOSS world (but not in the JRE) so I am a little more comfortable with
>>>>>> it.
>>>>>>
>>>>>> I still see plain old "Shutdown" as simpler.
>>>>>>
>>>>>> I think I've boiled down my feel for this name to the fact that the
>>>>>> Capable postfix is redundant since a class implementing any interface is
>>>>>> "capable" of that functionality. IOW we have Serializable vs.
>>>>>> SerializationCabable, which means the same thing.
>>>>>>
>>>>>> Gary
>>>>>>
>>>>>> On Mon, Jan 25, 2016 at 7:27 AM, Ralph Goers <
>>>>>> ralph.goers@dslextreme.com> wrote:
>>>>>>
>>>>>>> What does it feel weird to you?  To be honest, I originally named
>>>>>>> the interface ‘Shutdown” and then changed it since it really is about
>>>>>>> implementing a behavior and “Shutdown” alone doesn’t really describe that.
>>>>>>>
>>>>>>> Ralph
>>>>>>>
>>>>>>> On Jan 24, 2016, at 11:09 PM, Gary Gregory <ga...@gmail.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>> On Sun, Jan 24, 2016 at 10:07 PM, Gary Gregory <
>>>>>>> garydgregory@gmail.com> wrote:
>>>>>>>
>>>>>>>> On Sun, Jan 24, 2016 at 1:54 PM, Ralph Goers <
>>>>>>>> ralph.goers@dslextreme.com> wrote:
>>>>>>>>
>>>>>>>>> Yes, Shutdownable is too weird.
>>>>>>>>>
>>>>>>>>
>>>>>>>> How about calling it simply "Shutdown" then? FooCapable feels weird
>>>>>>>> to me.
>>>>>>>>
>>>>>>>> Can anyone think of other (one-method or not) optional feature-like
>>>>>>>> interfaces in the JRE or other code base?
>>>>>>>>
>>>>>>>
>>>>>>> hm... ShutdownService?
>>>>>>>
>>>>>>> Gary
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> Gary
>>>>>>>>
>>>>>>>> Closeable would imply there is a close method, not a shutdown
>>>>>>>>> method.  I have my doubts about the try-with-resources use case here.
>>>>>>>>> Virtually all usages are probably going to be to disable automatic shutdown
>>>>>>>>> and then the user placing the shutdown call somewhere they can control,
>>>>>>>>> which probably will have nothing to do with initialization of logging.
>>>>>>>>>
>>>>>>>>> Ralph
>>>>>>>>>
>>>>>>>>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <ga...@gmail.com>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> Resending, got a error from my phone...
>>>>>>>>> ---------- Forwarded message ----------
>>>>>>>>> From: "Gary Gregory" <ga...@gmail.com>
>>>>>>>>> Date: Jan 24, 2016 1:41 PM
>>>>>>>>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown
>>>>>>>>> methods to LogManager
>>>>>>>>> To: <de...@logging.apache.org>
>>>>>>>>> Cc:
>>>>>>>>>
>>>>>>>>> Hi all,
>>>>>>>>>
>>>>>>>>> Any reason not use the usual -able postfix instead of
>>>>>>>>> ShutdownCapable: Shutdownable sounds too weird? What about reusing plain
>>>>>>>>> old Closeable? That means you could use the context in a try-with-resources
>>>>>>>>> block, a bonus.
>>>>>>>>>
>>>>>>>>> Gary
>>>>>>>>> On Jan 24, 2016 10:18 AM, <rg...@apache.org> wrote:
>>>>>>>>>
>>>>>>>>>> Repository: logging-log4j2
>>>>>>>>>> Updated Branches:
>>>>>>>>>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> LOG4J2-124 - Add shutdown methods to LogManager
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Project:
>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>>>>>>>>> Commit:
>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7
>>>>>>>>>> Tree:
>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7
>>>>>>>>>> Diff:
>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7
>>>>>>>>>>
>>>>>>>>>> Branch: refs/heads/master
>>>>>>>>>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>>>>>>>>>> Parents: 7d3aac4
>>>>>>>>>> Author: Ralph Goers <rg...@nextiva.com>
>>>>>>>>>> Authored: Sun Jan 24 11:18:41 2016 -0700
>>>>>>>>>> Committer: Ralph Goers <rg...@nextiva.com>
>>>>>>>>>> Committed: Sun Jan 24 11:18:41 2016 -0700
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>  .../org/apache/logging/log4j/LogManager.java    | 62
>>>>>>>>>> ++++++++++++++++++++
>>>>>>>>>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>>>>>>>>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>>>>>>>>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>>>>>>>>>  4 files changed, 93 insertions(+), 1 deletion(-)
>>>>>>>>>>
>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>>>
>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>> diff --git
>>>>>>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>>> index f10e5a8..64c6ee5 100644
>>>>>>>>>> ---
>>>>>>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>>> +++
>>>>>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>>> @@ -27,6 +27,7 @@ import
>>>>>>>>>> org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContext;
>>>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>>>>>>  import org.apache.logging.log4j.spi.Provider;
>>>>>>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>>>>>>  import org.apache.logging.log4j.status.StatusLogger;
>>>>>>>>>>  import org.apache.logging.log4j.util.LoaderUtil;
>>>>>>>>>>  import org.apache.logging.log4j.util.PropertiesUtil;
>>>>>>>>>> @@ -285,6 +286,67 @@ public class LogManager {
>>>>>>>>>>      }
>>>>>>>>>>
>>>>>>>>>>      /**
>>>>>>>>>> +     * Shutdown using the default LoggerContext.
>>>>>>>>>> +     * @since 2.6
>>>>>>>>>> +     */
>>>>>>>>>> +    public static void shutdown() {
>>>>>>>>>> +        shutdown(getContext());
>>>>>>>>>> +    }
>>>>>>>>>> +
>>>>>>>>>> +    /**
>>>>>>>>>> +     * Shutdown the logging system if the logging system
>>>>>>>>>> supports it.
>>>>>>>>>> +     * @param currentContext if true the LoggerContext for the
>>>>>>>>>> caller of this method will be used.
>>>>>>>>>> +     * @since 2.6
>>>>>>>>>> +     */
>>>>>>>>>> +    public static void shutdown(boolean currentContext) {
>>>>>>>>>> +        shutdown(getContext(currentContext));
>>>>>>>>>> +    }
>>>>>>>>>> +
>>>>>>>>>> +    /**
>>>>>>>>>> +     * Shutdown the logging system if the logging system
>>>>>>>>>> supports it.
>>>>>>>>>> +     * @param loader The ClassLoader for the context. If null
>>>>>>>>>> the context will attempt to determine the appropriate
>>>>>>>>>> +     *            ClassLoader.
>>>>>>>>>> +     * @param currentContext if false the LoggerContext
>>>>>>>>>> appropriate for the caller of this method will be used.
>>>>>>>>>> +     * @since 2.6
>>>>>>>>>> +     */
>>>>>>>>>> +    public static void shutdown(final ClassLoader loader, final
>>>>>>>>>> boolean currentContext) {
>>>>>>>>>> +        shutdown(getContext(loader, currentContext));
>>>>>>>>>> +    }
>>>>>>>>>> +
>>>>>>>>>> +    /**
>>>>>>>>>> +     * Shutdown the logging system if the logging system
>>>>>>>>>> supports it.
>>>>>>>>>> +     * @param context the LoggerContext.
>>>>>>>>>> +     * @since 2.6
>>>>>>>>>> +     */
>>>>>>>>>> +    public static void shutdown(LoggerContext context) {
>>>>>>>>>> +        if (context != null && context instanceof
>>>>>>>>>> ShutdownCapable) {
>>>>>>>>>> +            ((ShutdownCapable) context).shutdown();
>>>>>>>>>> +        }
>>>>>>>>>> +    }
>>>>>>>>>> +
>>>>>>>>>> +    /**
>>>>>>>>>> +     * Shutdown the logging system if the logging system
>>>>>>>>>> supports it.
>>>>>>>>>> +     * @param fqcn The fully qualified class name of the Class
>>>>>>>>>> that this method is a member of.
>>>>>>>>>> +     * @param currentContext if false the LoggerContext
>>>>>>>>>> appropriate for the caller of this method will be used.
>>>>>>>>>> +     * @since 2.6
>>>>>>>>>> +     */
>>>>>>>>>> +    protected static void shutdown(final String fqcn, final
>>>>>>>>>> boolean currentContext) {
>>>>>>>>>> +        shutdown(getContext(fqcn, currentContext));
>>>>>>>>>> +    }
>>>>>>>>>> +
>>>>>>>>>> +    /**
>>>>>>>>>> +     * Shutdown the logging system if the logging system
>>>>>>>>>> supports it.
>>>>>>>>>> +     * @param fqcn The fully qualified class name of the Class
>>>>>>>>>> that this method is a member of.
>>>>>>>>>> +     * @param loader The ClassLoader for the context. If null
>>>>>>>>>> the context will attempt to determine the appropriate
>>>>>>>>>> +     *            ClassLoader.
>>>>>>>>>> +     * @param currentContext if false the LoggerContext
>>>>>>>>>> appropriate for the caller of this method will be used.
>>>>>>>>>> +     * @since 2.6
>>>>>>>>>> +     */
>>>>>>>>>> +    protected static void shutdown(final String fqcn, final
>>>>>>>>>> ClassLoader loader, final boolean currentContext) {
>>>>>>>>>> +        shutdown(getContext(fqcn, loader, currentContext));
>>>>>>>>>> +    }
>>>>>>>>>> +
>>>>>>>>>> +    /**
>>>>>>>>>>       * Returns the current LoggerContextFactory.
>>>>>>>>>>       *
>>>>>>>>>>       * @return The LoggerContextFactory.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>>>>
>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>> diff --git
>>>>>>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>>>> new file mode 100644
>>>>>>>>>> index 0000000..a46ef60
>>>>>>>>>> --- /dev/null
>>>>>>>>>> +++
>>>>>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>>>> @@ -0,0 +1,17 @@
>>>>>>>>>> +/*
>>>>>>>>>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>>>>>>>>>> + * All rights reserved.
>>>>>>>>>> + */
>>>>>>>>>> +package org.apache.logging.log4j.spi;
>>>>>>>>>> +
>>>>>>>>>> +/**
>>>>>>>>>> + * Interface to be implemented by LoggerContext's that provide a
>>>>>>>>>> shutdown method.
>>>>>>>>>> + * @since 2.6
>>>>>>>>>> + */
>>>>>>>>>> +public interface ShutdownCapable {
>>>>>>>>>> +
>>>>>>>>>> +    /**
>>>>>>>>>> +     * Requests that the logging implementation shut down.
>>>>>>>>>> +     */
>>>>>>>>>> +    void shutdown();
>>>>>>>>>> +}
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>>>
>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>> diff --git
>>>>>>>>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>>> index 48f0eea..596a9f2 100644
>>>>>>>>>> ---
>>>>>>>>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>>> +++
>>>>>>>>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>>> @@ -17,6 +17,7 @@
>>>>>>>>>>  package org.apache.logging.log4j;
>>>>>>>>>>
>>>>>>>>>>  import
>>>>>>>>>> org.apache.logging.log4j.message.ParameterizedMessageFactory;
>>>>>>>>>> +import org.apache.logging.log4j.spi.LoggerContext;
>>>>>>>>>>  import org.junit.Test;
>>>>>>>>>>
>>>>>>>>>>  import static org.junit.Assert.*;
>>>>>>>>>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>>>>>>>>>          assertNotNull("No Logger returned", logger);
>>>>>>>>>>          assertTrue("Incorrect Logger name: " +
>>>>>>>>>> logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>>>>>>>>>      }
>>>>>>>>>> +
>>>>>>>>>> +    @Test
>>>>>>>>>> +    public void testShutdown() {
>>>>>>>>>> +        LoggerContext loggerContext =
>>>>>>>>>> LogManager.getContext(false);
>>>>>>>>>> +        LogManager.shutdown(loggerContext);
>>>>>>>>>> +    }
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>>>
>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>> diff --git
>>>>>>>>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>>> index 42efbb5..fcdfc16 100644
>>>>>>>>>> ---
>>>>>>>>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>>> +++
>>>>>>>>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>>> @@ -45,6 +45,7 @@ import
>>>>>>>>>> org.apache.logging.log4j.message.MessageFactory;
>>>>>>>>>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>>>>>>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>>>>>>
>>>>>>>>>>  import static
>>>>>>>>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>>>>>>
>>>>>>>>>> @@ -54,7 +55,7 @@ import static
>>>>>>>>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>>>>>>   * filters, etc and will be atomically updated whenever a
>>>>>>>>>> reconfigure occurs.
>>>>>>>>>>   */
>>>>>>>>>>  public class LoggerContext extends AbstractLifeCycle implements
>>>>>>>>>> org.apache.logging.log4j.spi.LoggerContext,
>>>>>>>>>> -        ConfigurationListener {
>>>>>>>>>> +        ShutdownCapable, ConfigurationListener {
>>>>>>>>>>
>>>>>>>>>>      /**
>>>>>>>>>>       * Property name of the property change event fired if the
>>>>>>>>>> configuration is changed.
>>>>>>>>>> @@ -278,6 +279,11 @@ public class LoggerContext extends
>>>>>>>>>> AbstractLifeCycle implements org.apache.loggi
>>>>>>>>>>      }
>>>>>>>>>>
>>>>>>>>>>      @Override
>>>>>>>>>> +    public void shutdown() {
>>>>>>>>>> +        stop();
>>>>>>>>>> +    }
>>>>>>>>>> +
>>>>>>>>>> +    @Override
>>>>>>>>>>      public void stop() {
>>>>>>>>>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...",
>>>>>>>>>> getName(), this);
>>>>>>>>>>          configLock.lock();
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>>>>>> Java Persistence with Hibernate, Second Edition
>>>>>>>> <http://www.manning.com/bauer3/>
>>>>>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>>>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>>>>>> Blog: http://garygregory.wordpress.com
>>>>>>>> Home: http://garygregory.com/
>>>>>>>> Tweet! http://twitter.com/GaryGregory
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>>>>> Java Persistence with Hibernate, Second Edition
>>>>>>> <http://www.manning.com/bauer3/>
>>>>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>>>>> Blog: http://garygregory.wordpress.com
>>>>>>> Home: http://garygregory.com/
>>>>>>> Tweet! http://twitter.com/GaryGregory
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>>>> Java Persistence with Hibernate, Second Edition
>>>>>> <http://www.manning.com/bauer3/>
>>>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>>>> Blog: http://garygregory.wordpress.com
>>>>>> Home: http://garygregory.com/
>>>>>> Tweet! http://twitter.com/GaryGregory
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Matt Sicker <bo...@gmail.com>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Matt Sicker <bo...@gmail.com>
>>>>
>>>
>>>
>>>
>>> --
>>> [image: MagineTV]
>>>
>>> *Mikael Ståldal*
>>> Senior software developer
>>>
>>> *Magine TV*
>>> mikael.staldal@magine.com
>>> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>>>
>>> Privileged and/or Confidential Information may be contained in this
>>> message. If you are not the addressee indicated in this message
>>> (or responsible for delivery of the message to such a person), you may
>>> not copy or deliver this message to anyone. In such case,
>>> you should destroy this message and kindly notify the sender by reply
>>> email.
>>>
>>>
>
>
> --
> [image: MagineTV]
>
> *Mikael Ståldal*
> Senior software developer
>
> *Magine TV*
> mikael.staldal@magine.com
> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>
> Privileged and/or Confidential Information may be contained in this
> message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not
> copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply
> email.
>
>


-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.staldal@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.

Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Remko Popma <re...@gmail.com>.
Perhaps you also want to add this to the LogManager.shutdown() methods, since I imagine that's what people will actually use/look at. 

Sent from my iPhone

> On 2016/01/27, at 18:20, Mikael Ståldal <mi...@magine.com> wrote:
> 
> OK, done.
> 
>> On Wed, Jan 27, 2016 at 6:17 AM, Remko Popma <re...@gmail.com> wrote:
>> Mikael, feel free to update the javadoc when you have time. 
>> 
>> 
>>> On Wednesday, 27 January 2016, Remko Popma <re...@gmail.com> wrote:
>>> Since the async loggers and appenders will wait until their queue has been cleared by the background thread, it is a blocking call. 
>>> 
>>> We should probably add a sentence to the java doc to clarify this.  
>>> 
>>> Sent from my iPhone
>>> 
>>>> On 2016/01/26, at 18:15, Mikael Ståldal <mi...@magine.com> wrote:
>>>> 
>>>> I think that we should be clear, in Javadoc, about whether this new method is synchronous/blocking or not.
>>>> 
>>>> (I could say the same about quite a few existing methods as well, but let's at least start to be clear about new methods from now.)
>>>> 
>>>>> On Tue, Jan 26, 2016 at 1:31 AM, Matt Sicker <bo...@gmail.com> wrote:
>>>>> I like it!
>>>>> 
>>>>>> On 25 January 2016 at 18:23, Ralph Goers <ra...@dslextreme.com> wrote:
>>>>>> Then the method name would be terminate?  I could live with that.  I also like the fact that when something goes wrong with it then it would be interminable ;-)
>>>>>> 
>>>>>> Ralph
>>>>>> 
>>>>>>> On Jan 25, 2016, at 5:18 PM, Matt Sicker <bo...@gmail.com> wrote:
>>>>>>> 
>>>>>>> How about Terminable? It's even a real word to boot.
>>>>>>> 
>>>>>>> On 25 January 2016 at 18:15, Ralph Goers <ra...@dslextreme.com> wrote:
>>>>>>>> Yes, well - Serializable actually sounds like it should be a real word. Shutdownable doesn’t - in fact, my mail editor just split it into two words to “help” me. I take a different view. A class that declares it implements an interface isn’t “capable” of anything - it just implements the interface. The interface name is what tells you that the implementing class is able to do something, which is why you have Comparable instead of just Compare, Cloneable instead of just Clone,  or Closeable instead of just Close. Would you want Stop instead of Stoppable?  I view “able” as just a shorthand way of saying “Capable”, but unfortunately that just doesn’t sound right with Shutdown (at least to me).
>>>>>>>> 
>>>>>>>> Here are some “able” alternatives - presumably each would have a corresponding method name instead of shutdown:
>>>>>>>> Terminateable.
>>>>>>>> Completeable.
>>>>>>>> Concludeable.
>>>>>>>> Haltable.
>>>>>>>> Dismissable.
>>>>>>>> Expireable.
>>>>>>>> 
>>>>>>>> I suppose we could also use Stoppable but that seems odd since stop is part of Lifecycle.
>>>>>>>> 
>>>>>>>> Got a preference?
>>>>>>>> 
>>>>>>>> Ralph
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>>> On Jan 25, 2016, at 4:35 PM, Gary Gregory <ga...@gmail.com> wrote:
>>>>>>>>> 
>>>>>>>>> I see some interfaces with "*Capable*" in the name here and there in the FOSS world (but not in the JRE) so I am a little more comfortable with it. 
>>>>>>>>> 
>>>>>>>>> I still see plain old "Shutdown" as simpler. 
>>>>>>>>> 
>>>>>>>>> I think I've boiled down my feel for this name to the fact that the Capable postfix is redundant since a class implementing any interface is "capable" of that functionality. IOW we have Serializable vs. SerializationCabable, which means the same thing.
>>>>>>>>> 
>>>>>>>>> Gary
>>>>>>>>> 
>>>>>>>>>> On Mon, Jan 25, 2016 at 7:27 AM, Ralph Goers <ra...@dslextreme.com> wrote:
>>>>>>>>>> What does it feel weird to you?  To be honest, I originally named the interface ‘Shutdown” and then changed it since it really is about implementing a behavior and “Shutdown” alone doesn’t really describe that.
>>>>>>>>>> 
>>>>>>>>>> Ralph
>>>>>>>>>> 
>>>>>>>>>>> On Jan 24, 2016, at 11:09 PM, Gary Gregory <ga...@gmail.com> wrote:
>>>>>>>>>>> 
>>>>>>>>>>>> On Sun, Jan 24, 2016 at 10:07 PM, Gary Gregory <ga...@gmail.com> wrote:
>>>>>>>>>>>>> On Sun, Jan 24, 2016 at 1:54 PM, Ralph Goers <ra...@dslextreme.com> wrote:
>>>>>>>>>>>>> Yes, Shutdownable is too weird. 
>>>>>>>>>>>> 
>>>>>>>>>>>> How about calling it simply "Shutdown" then? FooCapable feels weird to me.
>>>>>>>>>>>> 
>>>>>>>>>>>> Can anyone think of other (one-method or not) optional feature-like interfaces in the JRE or other code base?
>>>>>>>>>>> 
>>>>>>>>>>> hm... ShutdownService?
>>>>>>>>>>> 
>>>>>>>>>>> Gary
>>>>>>>>>>>  
>>>>>>>>>>>> 
>>>>>>>>>>>> Gary
>>>>>>>>>>>> 
>>>>>>>>>>>>> Closeable would imply there is a close method, not a shutdown method.  I have my doubts about the try-with-resources use case here.  Virtually all usages are probably going to be to disable automatic shutdown and then the user placing the shutdown call somewhere they can control, which probably will have nothing to do with initialization of logging. 
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Ralph
>>>>>>>>>>>>> 
>>>>>>>>>>>>>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <ga...@gmail.com> wrote:
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Resending, got a error from my phone...
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> ---------- Forwarded message ----------
>>>>>>>>>>>>>> From: "Gary Gregory" <ga...@gmail.com>
>>>>>>>>>>>>>> Date: Jan 24, 2016 1:41 PM
>>>>>>>>>>>>>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager
>>>>>>>>>>>>>> To: <de...@logging.apache.org>
>>>>>>>>>>>>>> Cc: 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Hi all,
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Any reason not use the usual -able postfix instead of ShutdownCapable: Shutdownable sounds too weird? What about reusing plain old Closeable? That means you could use the context in a try-with-resources block, a bonus.
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Gary 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> On Jan 24, 2016 10:18 AM, <rg...@apache.org> wrote:
>>>>>>>>>>>>>>> Repository: logging-log4j2
>>>>>>>>>>>>>>> Updated Branches:
>>>>>>>>>>>>>>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> LOG4J2-124 - Add shutdown methods to LogManager
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>>>>>>>>>>>>>> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7
>>>>>>>>>>>>>>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7
>>>>>>>>>>>>>>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> Branch: refs/heads/master
>>>>>>>>>>>>>>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>>>>>>>>>>>>>>> Parents: 7d3aac4
>>>>>>>>>>>>>>> Author: Ralph Goers <rg...@nextiva.com>
>>>>>>>>>>>>>>> Authored: Sun Jan 24 11:18:41 2016 -0700
>>>>>>>>>>>>>>> Committer: Ralph Goers <rg...@nextiva.com>
>>>>>>>>>>>>>>> Committed: Sun Jan 24 11:18:41 2016 -0700
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>>>>  .../org/apache/logging/log4j/LogManager.java    | 62 ++++++++++++++++++++
>>>>>>>>>>>>>>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>>>>>>>>>>>>>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>>>>>>>>>>>>>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>>>>>>>>>>>>>>  4 files changed, 93 insertions(+), 1 deletion(-)
>>>>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>>>> diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>>>>>>>> index f10e5a8..64c6ee5 100644
>>>>>>>>>>>>>>> --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>>>>>>>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>>>>>>>> @@ -27,6 +27,7 @@ import org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>>>>>>>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContext;
>>>>>>>>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>>>>>>>>>>>  import org.apache.logging.log4j.spi.Provider;
>>>>>>>>>>>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>>>>>>>>>>>  import org.apache.logging.log4j.status.StatusLogger;
>>>>>>>>>>>>>>>  import org.apache.logging.log4j.util.LoaderUtil;
>>>>>>>>>>>>>>>  import org.apache.logging.log4j.util.PropertiesUtil;
>>>>>>>>>>>>>>> @@ -285,6 +286,67 @@ public class LogManager {
>>>>>>>>>>>>>>>      }
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>      /**
>>>>>>>>>>>>>>> +     * Shutdown using the default LoggerContext.
>>>>>>>>>>>>>>> +     * @since 2.6
>>>>>>>>>>>>>>> +     */
>>>>>>>>>>>>>>> +    public static void shutdown() {
>>>>>>>>>>>>>>> +        shutdown(getContext());
>>>>>>>>>>>>>>> +    }
>>>>>>>>>>>>>>> +
>>>>>>>>>>>>>>> +    /**
>>>>>>>>>>>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>>>>>>>>>>>> +     * @param currentContext if true the LoggerContext for the caller of this method will be used.
>>>>>>>>>>>>>>> +     * @since 2.6
>>>>>>>>>>>>>>> +     */
>>>>>>>>>>>>>>> +    public static void shutdown(boolean currentContext) {
>>>>>>>>>>>>>>> +        shutdown(getContext(currentContext));
>>>>>>>>>>>>>>> +    }
>>>>>>>>>>>>>>> +
>>>>>>>>>>>>>>> +    /**
>>>>>>>>>>>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>>>>>>>>>>>> +     * @param loader The ClassLoader for the context. If null the context will attempt to determine the appropriate
>>>>>>>>>>>>>>> +     *            ClassLoader.
>>>>>>>>>>>>>>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>>>>>>>>>>>>>>> +     * @since 2.6
>>>>>>>>>>>>>>> +     */
>>>>>>>>>>>>>>> +    public static void shutdown(final ClassLoader loader, final boolean currentContext) {
>>>>>>>>>>>>>>> +        shutdown(getContext(loader, currentContext));
>>>>>>>>>>>>>>> +    }
>>>>>>>>>>>>>>> +
>>>>>>>>>>>>>>> +    /**
>>>>>>>>>>>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>>>>>>>>>>>> +     * @param context the LoggerContext.
>>>>>>>>>>>>>>> +     * @since 2.6
>>>>>>>>>>>>>>> +     */
>>>>>>>>>>>>>>> +    public static void shutdown(LoggerContext context) {
>>>>>>>>>>>>>>> +        if (context != null && context instanceof ShutdownCapable) {
>>>>>>>>>>>>>>> +            ((ShutdownCapable) context).shutdown();
>>>>>>>>>>>>>>> +        }
>>>>>>>>>>>>>>> +    }
>>>>>>>>>>>>>>> +
>>>>>>>>>>>>>>> +    /**
>>>>>>>>>>>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>>>>>>>>>>>> +     * @param fqcn The fully qualified class name of the Class that this method is a member of.
>>>>>>>>>>>>>>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>>>>>>>>>>>>>>> +     * @since 2.6
>>>>>>>>>>>>>>> +     */
>>>>>>>>>>>>>>> +    protected static void shutdown(final String fqcn, final boolean currentContext) {
>>>>>>>>>>>>>>> +        shutdown(getContext(fqcn, currentContext));
>>>>>>>>>>>>>>> +    }
>>>>>>>>>>>>>>> +
>>>>>>>>>>>>>>> +    /**
>>>>>>>>>>>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>>>>>>>>>>>> +     * @param fqcn The fully qualified class name of the Class that this method is a member of.
>>>>>>>>>>>>>>> +     * @param loader The ClassLoader for the context. If null the context will attempt to determine the appropriate
>>>>>>>>>>>>>>> +     *            ClassLoader.
>>>>>>>>>>>>>>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>>>>>>>>>>>>>>> +     * @since 2.6
>>>>>>>>>>>>>>> +     */
>>>>>>>>>>>>>>> +    protected static void shutdown(final String fqcn, final ClassLoader loader, final boolean currentContext) {
>>>>>>>>>>>>>>> +        shutdown(getContext(fqcn, loader, currentContext));
>>>>>>>>>>>>>>> +    }
>>>>>>>>>>>>>>> +
>>>>>>>>>>>>>>> +    /**
>>>>>>>>>>>>>>>       * Returns the current LoggerContextFactory.
>>>>>>>>>>>>>>>       *
>>>>>>>>>>>>>>>       * @return The LoggerContextFactory.
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>>>> diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>>>>>>>>> new file mode 100644
>>>>>>>>>>>>>>> index 0000000..a46ef60
>>>>>>>>>>>>>>> --- /dev/null
>>>>>>>>>>>>>>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>>>>>>>>> @@ -0,0 +1,17 @@
>>>>>>>>>>>>>>> +/*
>>>>>>>>>>>>>>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>>>>>>>>>>>>>>> + * All rights reserved.
>>>>>>>>>>>>>>> + */
>>>>>>>>>>>>>>> +package org.apache.logging.log4j.spi;
>>>>>>>>>>>>>>> +
>>>>>>>>>>>>>>> +/**
>>>>>>>>>>>>>>> + * Interface to be implemented by LoggerContext's that provide a shutdown method.
>>>>>>>>>>>>>>> + * @since 2.6
>>>>>>>>>>>>>>> + */
>>>>>>>>>>>>>>> +public interface ShutdownCapable {
>>>>>>>>>>>>>>> +
>>>>>>>>>>>>>>> +    /**
>>>>>>>>>>>>>>> +     * Requests that the logging implementation shut down.
>>>>>>>>>>>>>>> +     */
>>>>>>>>>>>>>>> +    void shutdown();
>>>>>>>>>>>>>>> +}
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>>>> diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>>>>>>>> index 48f0eea..596a9f2 100644
>>>>>>>>>>>>>>> --- a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>>>>>>>> +++ b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>>>>>>>> @@ -17,6 +17,7 @@
>>>>>>>>>>>>>>>  package org.apache.logging.log4j;
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>  import org.apache.logging.log4j.message.ParameterizedMessageFactory;
>>>>>>>>>>>>>>> +import org.apache.logging.log4j.spi.LoggerContext;
>>>>>>>>>>>>>>>  import org.junit.Test;
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>  import static org.junit.Assert.*;
>>>>>>>>>>>>>>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>>>>>>>>>>>>>>          assertNotNull("No Logger returned", logger);
>>>>>>>>>>>>>>>          assertTrue("Incorrect Logger name: " + logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>>>>>>>>>>>>>>      }
>>>>>>>>>>>>>>> +
>>>>>>>>>>>>>>> +    @Test
>>>>>>>>>>>>>>> +    public void testShutdown() {
>>>>>>>>>>>>>>> +        LoggerContext loggerContext = LogManager.getContext(false);
>>>>>>>>>>>>>>> +        LogManager.shutdown(loggerContext);
>>>>>>>>>>>>>>> +    }
>>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>>>> diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>>>>>>>> index 42efbb5..fcdfc16 100644
>>>>>>>>>>>>>>> --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>>>>>>>> +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>>>>>>>> @@ -45,6 +45,7 @@ import org.apache.logging.log4j.message.MessageFactory;
>>>>>>>>>>>>>>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>>>>>>>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>>>>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>>>>>>>>>>>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>  import static org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> @@ -54,7 +55,7 @@ import static org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>>>>>>>>>>>   * filters, etc and will be atomically updated whenever a reconfigure occurs.
>>>>>>>>>>>>>>>   */
>>>>>>>>>>>>>>>  public class LoggerContext extends AbstractLifeCycle implements org.apache.logging.log4j.spi.LoggerContext,
>>>>>>>>>>>>>>> -        ConfigurationListener {
>>>>>>>>>>>>>>> +        ShutdownCapable, ConfigurationListener {
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>      /**
>>>>>>>>>>>>>>>       * Property name of the property change event fired if the configuration is changed.
>>>>>>>>>>>>>>> @@ -278,6 +279,11 @@ public class LoggerContext extends AbstractLifeCycle implements org.apache.loggi
>>>>>>>>>>>>>>>      }
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>      @Override
>>>>>>>>>>>>>>> +    public void shutdown() {
>>>>>>>>>>>>>>> +        stop();
>>>>>>>>>>>>>>> +    }
>>>>>>>>>>>>>>> +
>>>>>>>>>>>>>>> +    @Override
>>>>>>>>>>>>>>>      public void stop() {
>>>>>>>>>>>>>>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...", getName(), this);
>>>>>>>>>>>>>>>          configLock.lock();
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> -- 
>>>>>>>>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org 
>>>>>>>>>>>> Java Persistence with Hibernate, Second Edition
>>>>>>>>>>>> JUnit in Action, Second Edition
>>>>>>>>>>>> Spring Batch in Action
>>>>>>>>>>>> Blog: http://garygregory.wordpress.com 
>>>>>>>>>>>> Home: http://garygregory.com/
>>>>>>>>>>>> Tweet! http://twitter.com/GaryGregory
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> -- 
>>>>>>>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org 
>>>>>>>>>>> Java Persistence with Hibernate, Second Edition
>>>>>>>>>>> JUnit in Action, Second Edition
>>>>>>>>>>> Spring Batch in Action
>>>>>>>>>>> Blog: http://garygregory.wordpress.com 
>>>>>>>>>>> Home: http://garygregory.com/
>>>>>>>>>>> Tweet! http://twitter.com/GaryGregory
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> -- 
>>>>>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org 
>>>>>>>>> Java Persistence with Hibernate, Second Edition
>>>>>>>>> JUnit in Action, Second Edition
>>>>>>>>> Spring Batch in Action
>>>>>>>>> Blog: http://garygregory.wordpress.com 
>>>>>>>>> Home: http://garygregory.com/
>>>>>>>>> Tweet! http://twitter.com/GaryGregory
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> -- 
>>>>>>> Matt Sicker <bo...@gmail.com>
>>>>> 
>>>>> 
>>>>> 
>>>>> -- 
>>>>> Matt Sicker <bo...@gmail.com>
>>>> 
>>>> 
>>>> 
>>>> -- 
>>>>  
>>>> 
>>>> Mikael Ståldal
>>>> Senior software developer 
>>>> 
>>>> Magine TV
>>>> mikael.staldal@magine.com    
>>>> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com 
>>>> 
>>>> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
>>>> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case, 
>>>> you should destroy this message and kindly notify the sender by reply email.   
> 
> 
> 
> -- 
>  
> 
> Mikael Ståldal
> Senior software developer 
> 
> Magine TV
> mikael.staldal@magine.com    
> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com             
> 
> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case, 
> you should destroy this message and kindly notify the sender by reply email.   

Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Mikael Ståldal <mi...@magine.com>.
OK, done.

On Wed, Jan 27, 2016 at 6:17 AM, Remko Popma <re...@gmail.com> wrote:

> Mikael, feel free to update the javadoc when you have time.
>
>
> On Wednesday, 27 January 2016, Remko Popma <re...@gmail.com> wrote:
>
>> Since the async loggers and appenders will wait until their queue has
>> been cleared by the background thread, it is a blocking call.
>>
>> We should probably add a sentence to the java doc to clarify this.
>>
>> Sent from my iPhone
>>
>> On 2016/01/26, at 18:15, Mikael Ståldal <mi...@magine.com>
>> wrote:
>>
>> I think that we should be clear, in Javadoc, about whether this new
>> method is synchronous/blocking or not.
>>
>> (I could say the same about quite a few existing methods as well, but
>> let's at least start to be clear about new methods from now.)
>>
>> On Tue, Jan 26, 2016 at 1:31 AM, Matt Sicker <bo...@gmail.com> wrote:
>>
>>> I like it!
>>>
>>> On 25 January 2016 at 18:23, Ralph Goers <ra...@dslextreme.com>
>>> wrote:
>>>
>>>> Then the method name would be terminate?  I could live with that.  I
>>>> also like the fact that when something goes wrong with it then it would be
>>>> interminable ;-)
>>>>
>>>> Ralph
>>>>
>>>> On Jan 25, 2016, at 5:18 PM, Matt Sicker <bo...@gmail.com> wrote:
>>>>
>>>> How about Terminable? It's even a real word to boot.
>>>>
>>>> On 25 January 2016 at 18:15, Ralph Goers <ra...@dslextreme.com>
>>>> wrote:
>>>>
>>>>> Yes, well - Serializable actually sounds like it should be a real
>>>>> word. Shutdownable doesn’t - in fact, my mail editor just split it into two
>>>>> words to “help” me. I take a different view. A class that declares it
>>>>> implements an interface isn’t “capable” of anything - it just implements
>>>>> the interface. The interface name is what tells you that the implementing
>>>>> class is able to do something, which is why you have Comparable instead of
>>>>> just Compare, Cloneable instead of just Clone,  or Closeable instead of
>>>>> just Close. Would you want Stop instead of Stoppable?  I view “able” as
>>>>> just a shorthand way of saying “Capable”, but unfortunately that just
>>>>> doesn’t sound right with Shutdown (at least to me).
>>>>>
>>>>> Here are some “able” alternatives - presumably each would have a
>>>>> corresponding method name instead of shutdown:
>>>>> Terminateable.
>>>>> Completeable.
>>>>> Concludeable.
>>>>> Haltable.
>>>>> Dismissable.
>>>>> Expireable.
>>>>>
>>>>> I suppose we could also use Stoppable but that seems odd since stop is
>>>>> part of Lifecycle.
>>>>>
>>>>> Got a preference?
>>>>>
>>>>> Ralph
>>>>>
>>>>>
>>>>>
>>>>> On Jan 25, 2016, at 4:35 PM, Gary Gregory <ga...@gmail.com>
>>>>> wrote:
>>>>>
>>>>> I see some interfaces with "*Capable*" in the name here and there in
>>>>> the FOSS world (but not in the JRE) so I am a little more comfortable with
>>>>> it.
>>>>>
>>>>> I still see plain old "Shutdown" as simpler.
>>>>>
>>>>> I think I've boiled down my feel for this name to the fact that the
>>>>> Capable postfix is redundant since a class implementing any interface is
>>>>> "capable" of that functionality. IOW we have Serializable vs.
>>>>> SerializationCabable, which means the same thing.
>>>>>
>>>>> Gary
>>>>>
>>>>> On Mon, Jan 25, 2016 at 7:27 AM, Ralph Goers <
>>>>> ralph.goers@dslextreme.com> wrote:
>>>>>
>>>>>> What does it feel weird to you?  To be honest, I originally named the
>>>>>> interface ‘Shutdown” and then changed it since it really is about
>>>>>> implementing a behavior and “Shutdown” alone doesn’t really describe that.
>>>>>>
>>>>>> Ralph
>>>>>>
>>>>>> On Jan 24, 2016, at 11:09 PM, Gary Gregory <ga...@gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>> On Sun, Jan 24, 2016 at 10:07 PM, Gary Gregory <
>>>>>> garydgregory@gmail.com> wrote:
>>>>>>
>>>>>>> On Sun, Jan 24, 2016 at 1:54 PM, Ralph Goers <
>>>>>>> ralph.goers@dslextreme.com> wrote:
>>>>>>>
>>>>>>>> Yes, Shutdownable is too weird.
>>>>>>>>
>>>>>>>
>>>>>>> How about calling it simply "Shutdown" then? FooCapable feels weird
>>>>>>> to me.
>>>>>>>
>>>>>>> Can anyone think of other (one-method or not) optional feature-like
>>>>>>> interfaces in the JRE or other code base?
>>>>>>>
>>>>>>
>>>>>> hm... ShutdownService?
>>>>>>
>>>>>> Gary
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> Gary
>>>>>>>
>>>>>>> Closeable would imply there is a close method, not a shutdown
>>>>>>>> method.  I have my doubts about the try-with-resources use case here.
>>>>>>>> Virtually all usages are probably going to be to disable automatic shutdown
>>>>>>>> and then the user placing the shutdown call somewhere they can control,
>>>>>>>> which probably will have nothing to do with initialization of logging.
>>>>>>>>
>>>>>>>> Ralph
>>>>>>>>
>>>>>>>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <ga...@gmail.com>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Resending, got a error from my phone...
>>>>>>>> ---------- Forwarded message ----------
>>>>>>>> From: "Gary Gregory" <ga...@gmail.com>
>>>>>>>> Date: Jan 24, 2016 1:41 PM
>>>>>>>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown
>>>>>>>> methods to LogManager
>>>>>>>> To: <de...@logging.apache.org>
>>>>>>>> Cc:
>>>>>>>>
>>>>>>>> Hi all,
>>>>>>>>
>>>>>>>> Any reason not use the usual -able postfix instead of
>>>>>>>> ShutdownCapable: Shutdownable sounds too weird? What about reusing plain
>>>>>>>> old Closeable? That means you could use the context in a try-with-resources
>>>>>>>> block, a bonus.
>>>>>>>>
>>>>>>>> Gary
>>>>>>>> On Jan 24, 2016 10:18 AM, <rg...@apache.org> wrote:
>>>>>>>>
>>>>>>>>> Repository: logging-log4j2
>>>>>>>>> Updated Branches:
>>>>>>>>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> LOG4J2-124 - Add shutdown methods to LogManager
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Project:
>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>>>>>>>> Commit:
>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7
>>>>>>>>> Tree:
>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7
>>>>>>>>> Diff:
>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7
>>>>>>>>>
>>>>>>>>> Branch: refs/heads/master
>>>>>>>>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>>>>>>>>> Parents: 7d3aac4
>>>>>>>>> Author: Ralph Goers <rg...@nextiva.com>
>>>>>>>>> Authored: Sun Jan 24 11:18:41 2016 -0700
>>>>>>>>> Committer: Ralph Goers <rg...@nextiva.com>
>>>>>>>>> Committed: Sun Jan 24 11:18:41 2016 -0700
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>  .../org/apache/logging/log4j/LogManager.java    | 62
>>>>>>>>> ++++++++++++++++++++
>>>>>>>>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>>>>>>>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>>>>>>>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>>>>>>>>  4 files changed, 93 insertions(+), 1 deletion(-)
>>>>>>>>>
>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>>
>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>> diff --git
>>>>>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>> index f10e5a8..64c6ee5 100644
>>>>>>>>> ---
>>>>>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>> +++
>>>>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>> @@ -27,6 +27,7 @@ import
>>>>>>>>> org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContext;
>>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>>>>>  import org.apache.logging.log4j.spi.Provider;
>>>>>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>>>>>  import org.apache.logging.log4j.status.StatusLogger;
>>>>>>>>>  import org.apache.logging.log4j.util.LoaderUtil;
>>>>>>>>>  import org.apache.logging.log4j.util.PropertiesUtil;
>>>>>>>>> @@ -285,6 +286,67 @@ public class LogManager {
>>>>>>>>>      }
>>>>>>>>>
>>>>>>>>>      /**
>>>>>>>>> +     * Shutdown using the default LoggerContext.
>>>>>>>>> +     * @since 2.6
>>>>>>>>> +     */
>>>>>>>>> +    public static void shutdown() {
>>>>>>>>> +        shutdown(getContext());
>>>>>>>>> +    }
>>>>>>>>> +
>>>>>>>>> +    /**
>>>>>>>>> +     * Shutdown the logging system if the logging system supports
>>>>>>>>> it.
>>>>>>>>> +     * @param currentContext if true the LoggerContext for the
>>>>>>>>> caller of this method will be used.
>>>>>>>>> +     * @since 2.6
>>>>>>>>> +     */
>>>>>>>>> +    public static void shutdown(boolean currentContext) {
>>>>>>>>> +        shutdown(getContext(currentContext));
>>>>>>>>> +    }
>>>>>>>>> +
>>>>>>>>> +    /**
>>>>>>>>> +     * Shutdown the logging system if the logging system supports
>>>>>>>>> it.
>>>>>>>>> +     * @param loader The ClassLoader for the context. If null the
>>>>>>>>> context will attempt to determine the appropriate
>>>>>>>>> +     *            ClassLoader.
>>>>>>>>> +     * @param currentContext if false the LoggerContext
>>>>>>>>> appropriate for the caller of this method will be used.
>>>>>>>>> +     * @since 2.6
>>>>>>>>> +     */
>>>>>>>>> +    public static void shutdown(final ClassLoader loader, final
>>>>>>>>> boolean currentContext) {
>>>>>>>>> +        shutdown(getContext(loader, currentContext));
>>>>>>>>> +    }
>>>>>>>>> +
>>>>>>>>> +    /**
>>>>>>>>> +     * Shutdown the logging system if the logging system supports
>>>>>>>>> it.
>>>>>>>>> +     * @param context the LoggerContext.
>>>>>>>>> +     * @since 2.6
>>>>>>>>> +     */
>>>>>>>>> +    public static void shutdown(LoggerContext context) {
>>>>>>>>> +        if (context != null && context instanceof
>>>>>>>>> ShutdownCapable) {
>>>>>>>>> +            ((ShutdownCapable) context).shutdown();
>>>>>>>>> +        }
>>>>>>>>> +    }
>>>>>>>>> +
>>>>>>>>> +    /**
>>>>>>>>> +     * Shutdown the logging system if the logging system supports
>>>>>>>>> it.
>>>>>>>>> +     * @param fqcn The fully qualified class name of the Class
>>>>>>>>> that this method is a member of.
>>>>>>>>> +     * @param currentContext if false the LoggerContext
>>>>>>>>> appropriate for the caller of this method will be used.
>>>>>>>>> +     * @since 2.6
>>>>>>>>> +     */
>>>>>>>>> +    protected static void shutdown(final String fqcn, final
>>>>>>>>> boolean currentContext) {
>>>>>>>>> +        shutdown(getContext(fqcn, currentContext));
>>>>>>>>> +    }
>>>>>>>>> +
>>>>>>>>> +    /**
>>>>>>>>> +     * Shutdown the logging system if the logging system supports
>>>>>>>>> it.
>>>>>>>>> +     * @param fqcn The fully qualified class name of the Class
>>>>>>>>> that this method is a member of.
>>>>>>>>> +     * @param loader The ClassLoader for the context. If null the
>>>>>>>>> context will attempt to determine the appropriate
>>>>>>>>> +     *            ClassLoader.
>>>>>>>>> +     * @param currentContext if false the LoggerContext
>>>>>>>>> appropriate for the caller of this method will be used.
>>>>>>>>> +     * @since 2.6
>>>>>>>>> +     */
>>>>>>>>> +    protected static void shutdown(final String fqcn, final
>>>>>>>>> ClassLoader loader, final boolean currentContext) {
>>>>>>>>> +        shutdown(getContext(fqcn, loader, currentContext));
>>>>>>>>> +    }
>>>>>>>>> +
>>>>>>>>> +    /**
>>>>>>>>>       * Returns the current LoggerContextFactory.
>>>>>>>>>       *
>>>>>>>>>       * @return The LoggerContextFactory.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>>>
>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>> diff --git
>>>>>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>>> new file mode 100644
>>>>>>>>> index 0000000..a46ef60
>>>>>>>>> --- /dev/null
>>>>>>>>> +++
>>>>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>>> @@ -0,0 +1,17 @@
>>>>>>>>> +/*
>>>>>>>>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>>>>>>>>> + * All rights reserved.
>>>>>>>>> + */
>>>>>>>>> +package org.apache.logging.log4j.spi;
>>>>>>>>> +
>>>>>>>>> +/**
>>>>>>>>> + * Interface to be implemented by LoggerContext's that provide a
>>>>>>>>> shutdown method.
>>>>>>>>> + * @since 2.6
>>>>>>>>> + */
>>>>>>>>> +public interface ShutdownCapable {
>>>>>>>>> +
>>>>>>>>> +    /**
>>>>>>>>> +     * Requests that the logging implementation shut down.
>>>>>>>>> +     */
>>>>>>>>> +    void shutdown();
>>>>>>>>> +}
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>>
>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>> diff --git
>>>>>>>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>> index 48f0eea..596a9f2 100644
>>>>>>>>> ---
>>>>>>>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>> +++
>>>>>>>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>> @@ -17,6 +17,7 @@
>>>>>>>>>  package org.apache.logging.log4j;
>>>>>>>>>
>>>>>>>>>  import
>>>>>>>>> org.apache.logging.log4j.message.ParameterizedMessageFactory;
>>>>>>>>> +import org.apache.logging.log4j.spi.LoggerContext;
>>>>>>>>>  import org.junit.Test;
>>>>>>>>>
>>>>>>>>>  import static org.junit.Assert.*;
>>>>>>>>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>>>>>>>>          assertNotNull("No Logger returned", logger);
>>>>>>>>>          assertTrue("Incorrect Logger name: " +
>>>>>>>>> logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>>>>>>>>      }
>>>>>>>>> +
>>>>>>>>> +    @Test
>>>>>>>>> +    public void testShutdown() {
>>>>>>>>> +        LoggerContext loggerContext =
>>>>>>>>> LogManager.getContext(false);
>>>>>>>>> +        LogManager.shutdown(loggerContext);
>>>>>>>>> +    }
>>>>>>>>>  }
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>>
>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>> diff --git
>>>>>>>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>> index 42efbb5..fcdfc16 100644
>>>>>>>>> ---
>>>>>>>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>> +++
>>>>>>>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>> @@ -45,6 +45,7 @@ import
>>>>>>>>> org.apache.logging.log4j.message.MessageFactory;
>>>>>>>>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>>>>>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>>>>>
>>>>>>>>>  import static
>>>>>>>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>>>>>
>>>>>>>>> @@ -54,7 +55,7 @@ import static
>>>>>>>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>>>>>   * filters, etc and will be atomically updated whenever a
>>>>>>>>> reconfigure occurs.
>>>>>>>>>   */
>>>>>>>>>  public class LoggerContext extends AbstractLifeCycle implements
>>>>>>>>> org.apache.logging.log4j.spi.LoggerContext,
>>>>>>>>> -        ConfigurationListener {
>>>>>>>>> +        ShutdownCapable, ConfigurationListener {
>>>>>>>>>
>>>>>>>>>      /**
>>>>>>>>>       * Property name of the property change event fired if the
>>>>>>>>> configuration is changed.
>>>>>>>>> @@ -278,6 +279,11 @@ public class LoggerContext extends
>>>>>>>>> AbstractLifeCycle implements org.apache.loggi
>>>>>>>>>      }
>>>>>>>>>
>>>>>>>>>      @Override
>>>>>>>>> +    public void shutdown() {
>>>>>>>>> +        stop();
>>>>>>>>> +    }
>>>>>>>>> +
>>>>>>>>> +    @Override
>>>>>>>>>      public void stop() {
>>>>>>>>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...",
>>>>>>>>> getName(), this);
>>>>>>>>>          configLock.lock();
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>>>>> Java Persistence with Hibernate, Second Edition
>>>>>>> <http://www.manning.com/bauer3/>
>>>>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>>>>> Blog: http://garygregory.wordpress.com
>>>>>>> Home: http://garygregory.com/
>>>>>>> Tweet! http://twitter.com/GaryGregory
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>>>> Java Persistence with Hibernate, Second Edition
>>>>>> <http://www.manning.com/bauer3/>
>>>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>>>> Blog: http://garygregory.wordpress.com
>>>>>> Home: http://garygregory.com/
>>>>>> Tweet! http://twitter.com/GaryGregory
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>>> Java Persistence with Hibernate, Second Edition
>>>>> <http://www.manning.com/bauer3/>
>>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>>> Blog: http://garygregory.wordpress.com
>>>>> Home: http://garygregory.com/
>>>>> Tweet! http://twitter.com/GaryGregory
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Matt Sicker <bo...@gmail.com>
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Matt Sicker <bo...@gmail.com>
>>>
>>
>>
>>
>> --
>> [image: MagineTV]
>>
>> *Mikael Ståldal*
>> Senior software developer
>>
>> *Magine TV*
>> mikael.staldal@magine.com
>> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>>
>> Privileged and/or Confidential Information may be contained in this
>> message. If you are not the addressee indicated in this message
>> (or responsible for delivery of the message to such a person), you may
>> not copy or deliver this message to anyone. In such case,
>> you should destroy this message and kindly notify the sender by reply
>> email.
>>
>>


-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.staldal@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.

Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Remko Popma <re...@gmail.com>.
Mikael, feel free to update the javadoc when you have time.

On Wednesday, 27 January 2016, Remko Popma <re...@gmail.com> wrote:

> Since the async loggers and appenders will wait until their queue has been
> cleared by the background thread, it is a blocking call.
>
> We should probably add a sentence to the java doc to clarify this.
>
> Sent from my iPhone
>
> On 2016/01/26, at 18:15, Mikael Ståldal <mikael.staldal@magine.com
> <javascript:_e(%7B%7D,'cvml','mikael.staldal@magine.com');>> wrote:
>
> I think that we should be clear, in Javadoc, about whether this new method
> is synchronous/blocking or not.
>
> (I could say the same about quite a few existing methods as well, but
> let's at least start to be clear about new methods from now.)
>
> On Tue, Jan 26, 2016 at 1:31 AM, Matt Sicker <boards@gmail.com
> <javascript:_e(%7B%7D,'cvml','boards@gmail.com');>> wrote:
>
>> I like it!
>>
>> On 25 January 2016 at 18:23, Ralph Goers <ralph.goers@dslextreme.com
>> <javascript:_e(%7B%7D,'cvml','ralph.goers@dslextreme.com');>> wrote:
>>
>>> Then the method name would be terminate?  I could live with that.  I
>>> also like the fact that when something goes wrong with it then it would be
>>> interminable ;-)
>>>
>>> Ralph
>>>
>>> On Jan 25, 2016, at 5:18 PM, Matt Sicker <boards@gmail.com
>>> <javascript:_e(%7B%7D,'cvml','boards@gmail.com');>> wrote:
>>>
>>> How about Terminable? It's even a real word to boot.
>>>
>>> On 25 January 2016 at 18:15, Ralph Goers <ralph.goers@dslextreme.com
>>> <javascript:_e(%7B%7D,'cvml','ralph.goers@dslextreme.com');>> wrote:
>>>
>>>> Yes, well - Serializable actually sounds like it should be a real word.
>>>> Shutdownable doesn’t - in fact, my mail editor just split it into two words
>>>> to “help” me. I take a different view. A class that declares it implements
>>>> an interface isn’t “capable” of anything - it just implements the
>>>> interface. The interface name is what tells you that the implementing class
>>>> is able to do something, which is why you have Comparable instead of just
>>>> Compare, Cloneable instead of just Clone,  or Closeable instead of just
>>>> Close. Would you want Stop instead of Stoppable?  I view “able” as just a
>>>> shorthand way of saying “Capable”, but unfortunately that just doesn’t
>>>> sound right with Shutdown (at least to me).
>>>>
>>>> Here are some “able” alternatives - presumably each would have a
>>>> corresponding method name instead of shutdown:
>>>> Terminateable.
>>>> Completeable.
>>>> Concludeable.
>>>> Haltable.
>>>> Dismissable.
>>>> Expireable.
>>>>
>>>> I suppose we could also use Stoppable but that seems odd since stop is
>>>> part of Lifecycle.
>>>>
>>>> Got a preference?
>>>>
>>>> Ralph
>>>>
>>>>
>>>>
>>>> On Jan 25, 2016, at 4:35 PM, Gary Gregory <garydgregory@gmail.com
>>>> <javascript:_e(%7B%7D,'cvml','garydgregory@gmail.com');>> wrote:
>>>>
>>>> I see some interfaces with "*Capable*" in the name here and there in
>>>> the FOSS world (but not in the JRE) so I am a little more comfortable with
>>>> it.
>>>>
>>>> I still see plain old "Shutdown" as simpler.
>>>>
>>>> I think I've boiled down my feel for this name to the fact that the
>>>> Capable postfix is redundant since a class implementing any interface is
>>>> "capable" of that functionality. IOW we have Serializable vs.
>>>> SerializationCabable, which means the same thing.
>>>>
>>>> Gary
>>>>
>>>> On Mon, Jan 25, 2016 at 7:27 AM, Ralph Goers <
>>>> ralph.goers@dslextreme.com
>>>> <javascript:_e(%7B%7D,'cvml','ralph.goers@dslextreme.com');>> wrote:
>>>>
>>>>> What does it feel weird to you?  To be honest, I originally named the
>>>>> interface ‘Shutdown” and then changed it since it really is about
>>>>> implementing a behavior and “Shutdown” alone doesn’t really describe that.
>>>>>
>>>>> Ralph
>>>>>
>>>>> On Jan 24, 2016, at 11:09 PM, Gary Gregory <garydgregory@gmail.com
>>>>> <javascript:_e(%7B%7D,'cvml','garydgregory@gmail.com');>> wrote:
>>>>>
>>>>> On Sun, Jan 24, 2016 at 10:07 PM, Gary Gregory <garydgregory@gmail.com
>>>>> <javascript:_e(%7B%7D,'cvml','garydgregory@gmail.com');>> wrote:
>>>>>
>>>>>> On Sun, Jan 24, 2016 at 1:54 PM, Ralph Goers <
>>>>>> ralph.goers@dslextreme.com
>>>>>> <javascript:_e(%7B%7D,'cvml','ralph.goers@dslextreme.com');>> wrote:
>>>>>>
>>>>>>> Yes, Shutdownable is too weird.
>>>>>>>
>>>>>>
>>>>>> How about calling it simply "Shutdown" then? FooCapable feels weird
>>>>>> to me.
>>>>>>
>>>>>> Can anyone think of other (one-method or not) optional feature-like
>>>>>> interfaces in the JRE or other code base?
>>>>>>
>>>>>
>>>>> hm... ShutdownService?
>>>>>
>>>>> Gary
>>>>>
>>>>>
>>>>>>
>>>>>> Gary
>>>>>>
>>>>>> Closeable would imply there is a close method, not a shutdown
>>>>>>> method.  I have my doubts about the try-with-resources use case here.
>>>>>>> Virtually all usages are probably going to be to disable automatic shutdown
>>>>>>> and then the user placing the shutdown call somewhere they can control,
>>>>>>> which probably will have nothing to do with initialization of logging.
>>>>>>>
>>>>>>> Ralph
>>>>>>>
>>>>>>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <garydgregory@gmail.com
>>>>>>> <javascript:_e(%7B%7D,'cvml','garydgregory@gmail.com');>> wrote:
>>>>>>>
>>>>>>> Resending, got a error from my phone...
>>>>>>> ---------- Forwarded message ----------
>>>>>>> From: "Gary Gregory" <garydgregory@gmail.com
>>>>>>> <javascript:_e(%7B%7D,'cvml','garydgregory@gmail.com');>>
>>>>>>> Date: Jan 24, 2016 1:41 PM
>>>>>>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown
>>>>>>> methods to LogManager
>>>>>>> To: <dev@logging.apache.org
>>>>>>> <javascript:_e(%7B%7D,'cvml','dev@logging.apache.org');>>
>>>>>>> Cc:
>>>>>>>
>>>>>>> Hi all,
>>>>>>>
>>>>>>> Any reason not use the usual -able postfix instead of
>>>>>>> ShutdownCapable: Shutdownable sounds too weird? What about reusing plain
>>>>>>> old Closeable? That means you could use the context in a try-with-resources
>>>>>>> block, a bonus.
>>>>>>>
>>>>>>> Gary
>>>>>>> On Jan 24, 2016 10:18 AM, <rgoers@apache.org
>>>>>>> <javascript:_e(%7B%7D,'cvml','rgoers@apache.org');>> wrote:
>>>>>>>
>>>>>>>> Repository: logging-log4j2
>>>>>>>> Updated Branches:
>>>>>>>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>>>>>>>>
>>>>>>>>
>>>>>>>> LOG4J2-124 - Add shutdown methods to LogManager
>>>>>>>>
>>>>>>>>
>>>>>>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>>>>>>> Commit:
>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7
>>>>>>>> Tree:
>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7
>>>>>>>> Diff:
>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7
>>>>>>>>
>>>>>>>> Branch: refs/heads/master
>>>>>>>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>>>>>>>> Parents: 7d3aac4
>>>>>>>> Author: Ralph Goers <rgoers@nextiva.com
>>>>>>>> <javascript:_e(%7B%7D,'cvml','rgoers@nextiva.com');>>
>>>>>>>> Authored: Sun Jan 24 11:18:41 2016 -0700
>>>>>>>> Committer: Ralph Goers <rgoers@nextiva.com
>>>>>>>> <javascript:_e(%7B%7D,'cvml','rgoers@nextiva.com');>>
>>>>>>>> Committed: Sun Jan 24 11:18:41 2016 -0700
>>>>>>>>
>>>>>>>>
>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>  .../org/apache/logging/log4j/LogManager.java    | 62
>>>>>>>> ++++++++++++++++++++
>>>>>>>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>>>>>>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>>>>>>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>>>>>>>  4 files changed, 93 insertions(+), 1 deletion(-)
>>>>>>>>
>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>
>>>>>>>> ----------------------------------------------------------------------
>>>>>>>> diff --git
>>>>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>> index f10e5a8..64c6ee5 100644
>>>>>>>> ---
>>>>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>> +++
>>>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>> @@ -27,6 +27,7 @@ import
>>>>>>>> org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContext;
>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>>>>  import org.apache.logging.log4j.spi.Provider;
>>>>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>>>>  import org.apache.logging.log4j.status.StatusLogger;
>>>>>>>>  import org.apache.logging.log4j.util.LoaderUtil;
>>>>>>>>  import org.apache.logging.log4j.util.PropertiesUtil;
>>>>>>>> @@ -285,6 +286,67 @@ public class LogManager {
>>>>>>>>      }
>>>>>>>>
>>>>>>>>      /**
>>>>>>>> +     * Shutdown using the default LoggerContext.
>>>>>>>> +     * @since 2.6
>>>>>>>> +     */
>>>>>>>> +    public static void shutdown() {
>>>>>>>> +        shutdown(getContext());
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>> +    /**
>>>>>>>> +     * Shutdown the logging system if the logging system supports
>>>>>>>> it.
>>>>>>>> +     * @param currentContext if true the LoggerContext for the
>>>>>>>> caller of this method will be used.
>>>>>>>> +     * @since 2.6
>>>>>>>> +     */
>>>>>>>> +    public static void shutdown(boolean currentContext) {
>>>>>>>> +        shutdown(getContext(currentContext));
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>> +    /**
>>>>>>>> +     * Shutdown the logging system if the logging system supports
>>>>>>>> it.
>>>>>>>> +     * @param loader The ClassLoader for the context. If null the
>>>>>>>> context will attempt to determine the appropriate
>>>>>>>> +     *            ClassLoader.
>>>>>>>> +     * @param currentContext if false the LoggerContext
>>>>>>>> appropriate for the caller of this method will be used.
>>>>>>>> +     * @since 2.6
>>>>>>>> +     */
>>>>>>>> +    public static void shutdown(final ClassLoader loader, final
>>>>>>>> boolean currentContext) {
>>>>>>>> +        shutdown(getContext(loader, currentContext));
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>> +    /**
>>>>>>>> +     * Shutdown the logging system if the logging system supports
>>>>>>>> it.
>>>>>>>> +     * @param context the LoggerContext.
>>>>>>>> +     * @since 2.6
>>>>>>>> +     */
>>>>>>>> +    public static void shutdown(LoggerContext context) {
>>>>>>>> +        if (context != null && context instanceof ShutdownCapable)
>>>>>>>> {
>>>>>>>> +            ((ShutdownCapable) context).shutdown();
>>>>>>>> +        }
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>> +    /**
>>>>>>>> +     * Shutdown the logging system if the logging system supports
>>>>>>>> it.
>>>>>>>> +     * @param fqcn The fully qualified class name of the Class
>>>>>>>> that this method is a member of.
>>>>>>>> +     * @param currentContext if false the LoggerContext
>>>>>>>> appropriate for the caller of this method will be used.
>>>>>>>> +     * @since 2.6
>>>>>>>> +     */
>>>>>>>> +    protected static void shutdown(final String fqcn, final
>>>>>>>> boolean currentContext) {
>>>>>>>> +        shutdown(getContext(fqcn, currentContext));
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>> +    /**
>>>>>>>> +     * Shutdown the logging system if the logging system supports
>>>>>>>> it.
>>>>>>>> +     * @param fqcn The fully qualified class name of the Class
>>>>>>>> that this method is a member of.
>>>>>>>> +     * @param loader The ClassLoader for the context. If null the
>>>>>>>> context will attempt to determine the appropriate
>>>>>>>> +     *            ClassLoader.
>>>>>>>> +     * @param currentContext if false the LoggerContext
>>>>>>>> appropriate for the caller of this method will be used.
>>>>>>>> +     * @since 2.6
>>>>>>>> +     */
>>>>>>>> +    protected static void shutdown(final String fqcn, final
>>>>>>>> ClassLoader loader, final boolean currentContext) {
>>>>>>>> +        shutdown(getContext(fqcn, loader, currentContext));
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>> +    /**
>>>>>>>>       * Returns the current LoggerContextFactory.
>>>>>>>>       *
>>>>>>>>       * @return The LoggerContextFactory.
>>>>>>>>
>>>>>>>>
>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>>
>>>>>>>> ----------------------------------------------------------------------
>>>>>>>> diff --git
>>>>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>> new file mode 100644
>>>>>>>> index 0000000..a46ef60
>>>>>>>> --- /dev/null
>>>>>>>> +++
>>>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>> @@ -0,0 +1,17 @@
>>>>>>>> +/*
>>>>>>>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>>>>>>>> + * All rights reserved.
>>>>>>>> + */
>>>>>>>> +package org.apache.logging.log4j.spi;
>>>>>>>> +
>>>>>>>> +/**
>>>>>>>> + * Interface to be implemented by LoggerContext's that provide a
>>>>>>>> shutdown method.
>>>>>>>> + * @since 2.6
>>>>>>>> + */
>>>>>>>> +public interface ShutdownCapable {
>>>>>>>> +
>>>>>>>> +    /**
>>>>>>>> +     * Requests that the logging implementation shut down.
>>>>>>>> +     */
>>>>>>>> +    void shutdown();
>>>>>>>> +}
>>>>>>>>
>>>>>>>>
>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>
>>>>>>>> ----------------------------------------------------------------------
>>>>>>>> diff --git
>>>>>>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>> index 48f0eea..596a9f2 100644
>>>>>>>> ---
>>>>>>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>> +++
>>>>>>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>> @@ -17,6 +17,7 @@
>>>>>>>>  package org.apache.logging.log4j;
>>>>>>>>
>>>>>>>>  import
>>>>>>>> org.apache.logging.log4j.message.ParameterizedMessageFactory;
>>>>>>>> +import org.apache.logging.log4j.spi.LoggerContext;
>>>>>>>>  import org.junit.Test;
>>>>>>>>
>>>>>>>>  import static org.junit.Assert.*;
>>>>>>>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>>>>>>>          assertNotNull("No Logger returned", logger);
>>>>>>>>          assertTrue("Incorrect Logger name: " +
>>>>>>>> logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>>>>>>>      }
>>>>>>>> +
>>>>>>>> +    @Test
>>>>>>>> +    public void testShutdown() {
>>>>>>>> +        LoggerContext loggerContext = LogManager.getContext(false);
>>>>>>>> +        LogManager.shutdown(loggerContext);
>>>>>>>> +    }
>>>>>>>>  }
>>>>>>>>
>>>>>>>>
>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>
>>>>>>>> ----------------------------------------------------------------------
>>>>>>>> diff --git
>>>>>>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>> index 42efbb5..fcdfc16 100644
>>>>>>>> ---
>>>>>>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>> +++
>>>>>>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>> @@ -45,6 +45,7 @@ import
>>>>>>>> org.apache.logging.log4j.message.MessageFactory;
>>>>>>>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>>>>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>>>>
>>>>>>>>  import static
>>>>>>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>>>>
>>>>>>>> @@ -54,7 +55,7 @@ import static
>>>>>>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>>>>   * filters, etc and will be atomically updated whenever a
>>>>>>>> reconfigure occurs.
>>>>>>>>   */
>>>>>>>>  public class LoggerContext extends AbstractLifeCycle implements
>>>>>>>> org.apache.logging.log4j.spi.LoggerContext,
>>>>>>>> -        ConfigurationListener {
>>>>>>>> +        ShutdownCapable, ConfigurationListener {
>>>>>>>>
>>>>>>>>      /**
>>>>>>>>       * Property name of the property change event fired if the
>>>>>>>> configuration is changed.
>>>>>>>> @@ -278,6 +279,11 @@ public class LoggerContext extends
>>>>>>>> AbstractLifeCycle implements org.apache.loggi
>>>>>>>>      }
>>>>>>>>
>>>>>>>>      @Override
>>>>>>>> +    public void shutdown() {
>>>>>>>> +        stop();
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>> +    @Override
>>>>>>>>      public void stop() {
>>>>>>>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...",
>>>>>>>> getName(), this);
>>>>>>>>          configLock.lock();
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> E-Mail: garydgregory@gmail.com
>>>>>> <javascript:_e(%7B%7D,'cvml','garydgregory@gmail.com');> |
>>>>>> ggregory@apache.org
>>>>>> <javascript:_e(%7B%7D,'cvml','ggregory@apache.org');>
>>>>>> Java Persistence with Hibernate, Second Edition
>>>>>> <http://www.manning.com/bauer3/>
>>>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>>>> Blog: http://garygregory.wordpress.com
>>>>>> Home: http://garygregory.com/
>>>>>> Tweet! http://twitter.com/GaryGregory
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> E-Mail: garydgregory@gmail.com
>>>>> <javascript:_e(%7B%7D,'cvml','garydgregory@gmail.com');> |
>>>>> ggregory@apache.org
>>>>> <javascript:_e(%7B%7D,'cvml','ggregory@apache.org');>
>>>>> Java Persistence with Hibernate, Second Edition
>>>>> <http://www.manning.com/bauer3/>
>>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>>> Blog: http://garygregory.wordpress.com
>>>>> Home: http://garygregory.com/
>>>>> Tweet! http://twitter.com/GaryGregory
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> E-Mail: garydgregory@gmail.com
>>>> <javascript:_e(%7B%7D,'cvml','garydgregory@gmail.com');> | ggregory@apache.org
>>>> <javascript:_e(%7B%7D,'cvml','ggregory@apache.org');>
>>>> Java Persistence with Hibernate, Second Edition
>>>> <http://www.manning.com/bauer3/>
>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>> Blog: http://garygregory.wordpress.com
>>>> Home: http://garygregory.com/
>>>> Tweet! http://twitter.com/GaryGregory
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Matt Sicker <boards@gmail.com
>>> <javascript:_e(%7B%7D,'cvml','boards@gmail.com');>>
>>>
>>>
>>>
>>
>>
>> --
>> Matt Sicker <boards@gmail.com
>> <javascript:_e(%7B%7D,'cvml','boards@gmail.com');>>
>>
>
>
>
> --
> [image: MagineTV]
>
> *Mikael Ståldal*
> Senior software developer
>
> *Magine TV*
> mikael.staldal@magine.com
> <javascript:_e(%7B%7D,'cvml','mikael.staldal@magine.com');>
> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>
> Privileged and/or Confidential Information may be contained in this
> message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not
> copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply
> email.
>
>

Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Remko Popma <re...@gmail.com>.
Since the async loggers and appenders will wait until their queue has been cleared by the background thread, it is a blocking call. 

We should probably add a sentence to the java doc to clarify this.  

Sent from my iPhone

> On 2016/01/26, at 18:15, Mikael Ståldal <mi...@magine.com> wrote:
> 
> I think that we should be clear, in Javadoc, about whether this new method is synchronous/blocking or not.
> 
> (I could say the same about quite a few existing methods as well, but let's at least start to be clear about new methods from now.)
> 
>> On Tue, Jan 26, 2016 at 1:31 AM, Matt Sicker <bo...@gmail.com> wrote:
>> I like it!
>> 
>>> On 25 January 2016 at 18:23, Ralph Goers <ra...@dslextreme.com> wrote:
>>> Then the method name would be terminate?  I could live with that.  I also like the fact that when something goes wrong with it then it would be interminable ;-)
>>> 
>>> Ralph
>>> 
>>>> On Jan 25, 2016, at 5:18 PM, Matt Sicker <bo...@gmail.com> wrote:
>>>> 
>>>> How about Terminable? It's even a real word to boot.
>>>> 
>>>> On 25 January 2016 at 18:15, Ralph Goers <ra...@dslextreme.com> wrote:
>>>>> Yes, well - Serializable actually sounds like it should be a real word. Shutdownable doesn’t - in fact, my mail editor just split it into two words to “help” me. I take a different view. A class that declares it implements an interface isn’t “capable” of anything - it just implements the interface. The interface name is what tells you that the implementing class is able to do something, which is why you have Comparable instead of just Compare, Cloneable instead of just Clone,  or Closeable instead of just Close. Would you want Stop instead of Stoppable?  I view “able” as just a shorthand way of saying “Capable”, but unfortunately that just doesn’t sound right with Shutdown (at least to me).
>>>>> 
>>>>> Here are some “able” alternatives - presumably each would have a corresponding method name instead of shutdown:
>>>>> Terminateable.
>>>>> Completeable.
>>>>> Concludeable.
>>>>> Haltable.
>>>>> Dismissable.
>>>>> Expireable.
>>>>> 
>>>>> I suppose we could also use Stoppable but that seems odd since stop is part of Lifecycle.
>>>>> 
>>>>> Got a preference?
>>>>> 
>>>>> Ralph
>>>>> 
>>>>> 
>>>>> 
>>>>>> On Jan 25, 2016, at 4:35 PM, Gary Gregory <ga...@gmail.com> wrote:
>>>>>> 
>>>>>> I see some interfaces with "*Capable*" in the name here and there in the FOSS world (but not in the JRE) so I am a little more comfortable with it. 
>>>>>> 
>>>>>> I still see plain old "Shutdown" as simpler. 
>>>>>> 
>>>>>> I think I've boiled down my feel for this name to the fact that the Capable postfix is redundant since a class implementing any interface is "capable" of that functionality. IOW we have Serializable vs. SerializationCabable, which means the same thing.
>>>>>> 
>>>>>> Gary
>>>>>> 
>>>>>>> On Mon, Jan 25, 2016 at 7:27 AM, Ralph Goers <ra...@dslextreme.com> wrote:
>>>>>>> What does it feel weird to you?  To be honest, I originally named the interface ‘Shutdown” and then changed it since it really is about implementing a behavior and “Shutdown” alone doesn’t really describe that.
>>>>>>> 
>>>>>>> Ralph
>>>>>>> 
>>>>>>>> On Jan 24, 2016, at 11:09 PM, Gary Gregory <ga...@gmail.com> wrote:
>>>>>>>> 
>>>>>>>>> On Sun, Jan 24, 2016 at 10:07 PM, Gary Gregory <ga...@gmail.com> wrote:
>>>>>>>>>> On Sun, Jan 24, 2016 at 1:54 PM, Ralph Goers <ra...@dslextreme.com> wrote:
>>>>>>>>>> Yes, Shutdownable is too weird. 
>>>>>>>>> 
>>>>>>>>> How about calling it simply "Shutdown" then? FooCapable feels weird to me.
>>>>>>>>> 
>>>>>>>>> Can anyone think of other (one-method or not) optional feature-like interfaces in the JRE or other code base?
>>>>>>>> 
>>>>>>>> hm... ShutdownService?
>>>>>>>> 
>>>>>>>> Gary
>>>>>>>>  
>>>>>>>>> 
>>>>>>>>> Gary
>>>>>>>>> 
>>>>>>>>>> Closeable would imply there is a close method, not a shutdown method.  I have my doubts about the try-with-resources use case here.  Virtually all usages are probably going to be to disable automatic shutdown and then the user placing the shutdown call somewhere they can control, which probably will have nothing to do with initialization of logging. 
>>>>>>>>>> 
>>>>>>>>>> Ralph
>>>>>>>>>> 
>>>>>>>>>>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <ga...@gmail.com> wrote:
>>>>>>>>>>> 
>>>>>>>>>>> Resending, got a error from my phone...
>>>>>>>>>>> 
>>>>>>>>>>> ---------- Forwarded message ----------
>>>>>>>>>>> From: "Gary Gregory" <ga...@gmail.com>
>>>>>>>>>>> Date: Jan 24, 2016 1:41 PM
>>>>>>>>>>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager
>>>>>>>>>>> To: <de...@logging.apache.org>
>>>>>>>>>>> Cc: 
>>>>>>>>>>> 
>>>>>>>>>>> Hi all,
>>>>>>>>>>> 
>>>>>>>>>>> Any reason not use the usual -able postfix instead of ShutdownCapable: Shutdownable sounds too weird? What about reusing plain old Closeable? That means you could use the context in a try-with-resources block, a bonus.
>>>>>>>>>>> 
>>>>>>>>>>> Gary 
>>>>>>>>>>> 
>>>>>>>>>>>> On Jan 24, 2016 10:18 AM, <rg...@apache.org> wrote:
>>>>>>>>>>>> Repository: logging-log4j2
>>>>>>>>>>>> Updated Branches:
>>>>>>>>>>>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> LOG4J2-124 - Add shutdown methods to LogManager
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>>>>>>>>>>> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7
>>>>>>>>>>>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7
>>>>>>>>>>>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7
>>>>>>>>>>>> 
>>>>>>>>>>>> Branch: refs/heads/master
>>>>>>>>>>>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>>>>>>>>>>>> Parents: 7d3aac4
>>>>>>>>>>>> Author: Ralph Goers <rg...@nextiva.com>
>>>>>>>>>>>> Authored: Sun Jan 24 11:18:41 2016 -0700
>>>>>>>>>>>> Committer: Ralph Goers <rg...@nextiva.com>
>>>>>>>>>>>> Committed: Sun Jan 24 11:18:41 2016 -0700
>>>>>>>>>>>> 
>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>  .../org/apache/logging/log4j/LogManager.java    | 62 ++++++++++++++++++++
>>>>>>>>>>>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>>>>>>>>>>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>>>>>>>>>>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>>>>>>>>>>>  4 files changed, 93 insertions(+), 1 deletion(-)
>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>> diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>>>>> index f10e5a8..64c6ee5 100644
>>>>>>>>>>>> --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>>>>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>>>>> @@ -27,6 +27,7 @@ import org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>>>>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContext;
>>>>>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>>>>>>>>  import org.apache.logging.log4j.spi.Provider;
>>>>>>>>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>>>>>>>>  import org.apache.logging.log4j.status.StatusLogger;
>>>>>>>>>>>>  import org.apache.logging.log4j.util.LoaderUtil;
>>>>>>>>>>>>  import org.apache.logging.log4j.util.PropertiesUtil;
>>>>>>>>>>>> @@ -285,6 +286,67 @@ public class LogManager {
>>>>>>>>>>>>      }
>>>>>>>>>>>> 
>>>>>>>>>>>>      /**
>>>>>>>>>>>> +     * Shutdown using the default LoggerContext.
>>>>>>>>>>>> +     * @since 2.6
>>>>>>>>>>>> +     */
>>>>>>>>>>>> +    public static void shutdown() {
>>>>>>>>>>>> +        shutdown(getContext());
>>>>>>>>>>>> +    }
>>>>>>>>>>>> +
>>>>>>>>>>>> +    /**
>>>>>>>>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>>>>>>>>> +     * @param currentContext if true the LoggerContext for the caller of this method will be used.
>>>>>>>>>>>> +     * @since 2.6
>>>>>>>>>>>> +     */
>>>>>>>>>>>> +    public static void shutdown(boolean currentContext) {
>>>>>>>>>>>> +        shutdown(getContext(currentContext));
>>>>>>>>>>>> +    }
>>>>>>>>>>>> +
>>>>>>>>>>>> +    /**
>>>>>>>>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>>>>>>>>> +     * @param loader The ClassLoader for the context. If null the context will attempt to determine the appropriate
>>>>>>>>>>>> +     *            ClassLoader.
>>>>>>>>>>>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>>>>>>>>>>>> +     * @since 2.6
>>>>>>>>>>>> +     */
>>>>>>>>>>>> +    public static void shutdown(final ClassLoader loader, final boolean currentContext) {
>>>>>>>>>>>> +        shutdown(getContext(loader, currentContext));
>>>>>>>>>>>> +    }
>>>>>>>>>>>> +
>>>>>>>>>>>> +    /**
>>>>>>>>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>>>>>>>>> +     * @param context the LoggerContext.
>>>>>>>>>>>> +     * @since 2.6
>>>>>>>>>>>> +     */
>>>>>>>>>>>> +    public static void shutdown(LoggerContext context) {
>>>>>>>>>>>> +        if (context != null && context instanceof ShutdownCapable) {
>>>>>>>>>>>> +            ((ShutdownCapable) context).shutdown();
>>>>>>>>>>>> +        }
>>>>>>>>>>>> +    }
>>>>>>>>>>>> +
>>>>>>>>>>>> +    /**
>>>>>>>>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>>>>>>>>> +     * @param fqcn The fully qualified class name of the Class that this method is a member of.
>>>>>>>>>>>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>>>>>>>>>>>> +     * @since 2.6
>>>>>>>>>>>> +     */
>>>>>>>>>>>> +    protected static void shutdown(final String fqcn, final boolean currentContext) {
>>>>>>>>>>>> +        shutdown(getContext(fqcn, currentContext));
>>>>>>>>>>>> +    }
>>>>>>>>>>>> +
>>>>>>>>>>>> +    /**
>>>>>>>>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>>>>>>>>> +     * @param fqcn The fully qualified class name of the Class that this method is a member of.
>>>>>>>>>>>> +     * @param loader The ClassLoader for the context. If null the context will attempt to determine the appropriate
>>>>>>>>>>>> +     *            ClassLoader.
>>>>>>>>>>>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>>>>>>>>>>>> +     * @since 2.6
>>>>>>>>>>>> +     */
>>>>>>>>>>>> +    protected static void shutdown(final String fqcn, final ClassLoader loader, final boolean currentContext) {
>>>>>>>>>>>> +        shutdown(getContext(fqcn, loader, currentContext));
>>>>>>>>>>>> +    }
>>>>>>>>>>>> +
>>>>>>>>>>>> +    /**
>>>>>>>>>>>>       * Returns the current LoggerContextFactory.
>>>>>>>>>>>>       *
>>>>>>>>>>>>       * @return The LoggerContextFactory.
>>>>>>>>>>>> 
>>>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>> diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>>>>>> new file mode 100644
>>>>>>>>>>>> index 0000000..a46ef60
>>>>>>>>>>>> --- /dev/null
>>>>>>>>>>>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>>>>>> @@ -0,0 +1,17 @@
>>>>>>>>>>>> +/*
>>>>>>>>>>>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>>>>>>>>>>>> + * All rights reserved.
>>>>>>>>>>>> + */
>>>>>>>>>>>> +package org.apache.logging.log4j.spi;
>>>>>>>>>>>> +
>>>>>>>>>>>> +/**
>>>>>>>>>>>> + * Interface to be implemented by LoggerContext's that provide a shutdown method.
>>>>>>>>>>>> + * @since 2.6
>>>>>>>>>>>> + */
>>>>>>>>>>>> +public interface ShutdownCapable {
>>>>>>>>>>>> +
>>>>>>>>>>>> +    /**
>>>>>>>>>>>> +     * Requests that the logging implementation shut down.
>>>>>>>>>>>> +     */
>>>>>>>>>>>> +    void shutdown();
>>>>>>>>>>>> +}
>>>>>>>>>>>> 
>>>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>> diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>>>>> index 48f0eea..596a9f2 100644
>>>>>>>>>>>> --- a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>>>>> +++ b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>>>>> @@ -17,6 +17,7 @@
>>>>>>>>>>>>  package org.apache.logging.log4j;
>>>>>>>>>>>> 
>>>>>>>>>>>>  import org.apache.logging.log4j.message.ParameterizedMessageFactory;
>>>>>>>>>>>> +import org.apache.logging.log4j.spi.LoggerContext;
>>>>>>>>>>>>  import org.junit.Test;
>>>>>>>>>>>> 
>>>>>>>>>>>>  import static org.junit.Assert.*;
>>>>>>>>>>>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>>>>>>>>>>>          assertNotNull("No Logger returned", logger);
>>>>>>>>>>>>          assertTrue("Incorrect Logger name: " + logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>>>>>>>>>>>      }
>>>>>>>>>>>> +
>>>>>>>>>>>> +    @Test
>>>>>>>>>>>> +    public void testShutdown() {
>>>>>>>>>>>> +        LoggerContext loggerContext = LogManager.getContext(false);
>>>>>>>>>>>> +        LogManager.shutdown(loggerContext);
>>>>>>>>>>>> +    }
>>>>>>>>>>>>  }
>>>>>>>>>>>> 
>>>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>> diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>>>>> index 42efbb5..fcdfc16 100644
>>>>>>>>>>>> --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>>>>> +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>>>>> @@ -45,6 +45,7 @@ import org.apache.logging.log4j.message.MessageFactory;
>>>>>>>>>>>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>>>>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>>>>>>>>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>>>>>>>> 
>>>>>>>>>>>>  import static org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>>>>>>>> 
>>>>>>>>>>>> @@ -54,7 +55,7 @@ import static org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>>>>>>>>   * filters, etc and will be atomically updated whenever a reconfigure occurs.
>>>>>>>>>>>>   */
>>>>>>>>>>>>  public class LoggerContext extends AbstractLifeCycle implements org.apache.logging.log4j.spi.LoggerContext,
>>>>>>>>>>>> -        ConfigurationListener {
>>>>>>>>>>>> +        ShutdownCapable, ConfigurationListener {
>>>>>>>>>>>> 
>>>>>>>>>>>>      /**
>>>>>>>>>>>>       * Property name of the property change event fired if the configuration is changed.
>>>>>>>>>>>> @@ -278,6 +279,11 @@ public class LoggerContext extends AbstractLifeCycle implements org.apache.loggi
>>>>>>>>>>>>      }
>>>>>>>>>>>> 
>>>>>>>>>>>>      @Override
>>>>>>>>>>>> +    public void shutdown() {
>>>>>>>>>>>> +        stop();
>>>>>>>>>>>> +    }
>>>>>>>>>>>> +
>>>>>>>>>>>> +    @Override
>>>>>>>>>>>>      public void stop() {
>>>>>>>>>>>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...", getName(), this);
>>>>>>>>>>>>          configLock.lock();
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> -- 
>>>>>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org 
>>>>>>>>> Java Persistence with Hibernate, Second Edition
>>>>>>>>> JUnit in Action, Second Edition
>>>>>>>>> Spring Batch in Action
>>>>>>>>> Blog: http://garygregory.wordpress.com 
>>>>>>>>> Home: http://garygregory.com/
>>>>>>>>> Tweet! http://twitter.com/GaryGregory
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> -- 
>>>>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org 
>>>>>>>> Java Persistence with Hibernate, Second Edition
>>>>>>>> JUnit in Action, Second Edition
>>>>>>>> Spring Batch in Action
>>>>>>>> Blog: http://garygregory.wordpress.com 
>>>>>>>> Home: http://garygregory.com/
>>>>>>>> Tweet! http://twitter.com/GaryGregory
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> -- 
>>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org 
>>>>>> Java Persistence with Hibernate, Second Edition
>>>>>> JUnit in Action, Second Edition
>>>>>> Spring Batch in Action
>>>>>> Blog: http://garygregory.wordpress.com 
>>>>>> Home: http://garygregory.com/
>>>>>> Tweet! http://twitter.com/GaryGregory
>>>> 
>>>> 
>>>> 
>>>> -- 
>>>> Matt Sicker <bo...@gmail.com>
>> 
>> 
>> 
>> -- 
>> Matt Sicker <bo...@gmail.com>
> 
> 
> 
> -- 
>  
> 
> Mikael Ståldal
> Senior software developer 
> 
> Magine TV
> mikael.staldal@magine.com    
> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com             
> 
> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case, 
> you should destroy this message and kindly notify the sender by reply email.   

Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Matt Sicker <bo...@gmail.com>.
My bad, I meant synchronized.

On 26 January 2016 at 09:52, Ralph Goers <ra...@dslextreme.com> wrote:

> I’m not sure what you mean Matt. It currently is synchronous as we don’t
> delegate the work to another thread - we directly call the LoggerContext
> which loops through and shuts down all the various components. IMO, making
> it asynchronous would be problematic as there would be no way to guarantee
> that the shutdown actually completed before the JVM terminated.
>
> Ralph
>
> On Jan 26, 2016, at 8:38 AM, Matt Sicker <bo...@gmail.com> wrote:
>
> Shutdown sounds like an execute once thing, so I don't see why it would
> need to be synchronous.
>
> On 26 January 2016 at 03:15, Mikael Ståldal <mi...@magine.com>
> wrote:
>
>> I think that we should be clear, in Javadoc, about whether this new
>> method is synchronous/blocking or not.
>>
>> (I could say the same about quite a few existing methods as well, but
>> let's at least start to be clear about new methods from now.)
>>
>> On Tue, Jan 26, 2016 at 1:31 AM, Matt Sicker <bo...@gmail.com> wrote:
>>
>>> I like it!
>>>
>>> On 25 January 2016 at 18:23, Ralph Goers <ra...@dslextreme.com>
>>> wrote:
>>>
>>>> Then the method name would be terminate?  I could live with that.  I
>>>> also like the fact that when something goes wrong with it then it would be
>>>> interminable ;-)
>>>>
>>>> Ralph
>>>>
>>>> On Jan 25, 2016, at 5:18 PM, Matt Sicker <bo...@gmail.com> wrote:
>>>>
>>>> How about Terminable? It's even a real word to boot.
>>>>
>>>> On 25 January 2016 at 18:15, Ralph Goers <ra...@dslextreme.com>
>>>> wrote:
>>>>
>>>>> Yes, well - Serializable actually sounds like it should be a real
>>>>> word. Shutdownable doesn’t - in fact, my mail editor just split it into two
>>>>> words to “help” me. I take a different view. A class that declares it
>>>>> implements an interface isn’t “capable” of anything - it just implements
>>>>> the interface. The interface name is what tells you that the implementing
>>>>> class is able to do something, which is why you have Comparable instead of
>>>>> just Compare, Cloneable instead of just Clone,  or Closeable instead of
>>>>> just Close. Would you want Stop instead of Stoppable?  I view “able” as
>>>>> just a shorthand way of saying “Capable”, but unfortunately that just
>>>>> doesn’t sound right with Shutdown (at least to me).
>>>>>
>>>>> Here are some “able” alternatives - presumably each would have a
>>>>> corresponding method name instead of shutdown:
>>>>> Terminateable.
>>>>> Completeable.
>>>>> Concludeable.
>>>>> Haltable.
>>>>> Dismissable.
>>>>> Expireable.
>>>>>
>>>>> I suppose we could also use Stoppable but that seems odd since stop is
>>>>> part of Lifecycle.
>>>>>
>>>>> Got a preference?
>>>>>
>>>>> Ralph
>>>>>
>>>>>
>>>>>
>>>>> On Jan 25, 2016, at 4:35 PM, Gary Gregory <ga...@gmail.com>
>>>>> wrote:
>>>>>
>>>>> I see some interfaces with "*Capable*" in the name here and there in
>>>>> the FOSS world (but not in the JRE) so I am a little more comfortable with
>>>>> it.
>>>>>
>>>>> I still see plain old "Shutdown" as simpler.
>>>>>
>>>>> I think I've boiled down my feel for this name to the fact that the
>>>>> Capable postfix is redundant since a class implementing any interface is
>>>>> "capable" of that functionality. IOW we have Serializable vs.
>>>>> SerializationCabable, which means the same thing.
>>>>>
>>>>> Gary
>>>>>
>>>>> On Mon, Jan 25, 2016 at 7:27 AM, Ralph Goers <
>>>>> ralph.goers@dslextreme.com> wrote:
>>>>>
>>>>>> What does it feel weird to you?  To be honest, I originally named the
>>>>>> interface ‘Shutdown” and then changed it since it really is about
>>>>>> implementing a behavior and “Shutdown” alone doesn’t really describe that.
>>>>>>
>>>>>> Ralph
>>>>>>
>>>>>> On Jan 24, 2016, at 11:09 PM, Gary Gregory <ga...@gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>> On Sun, Jan 24, 2016 at 10:07 PM, Gary Gregory <
>>>>>> garydgregory@gmail.com> wrote:
>>>>>>
>>>>>>> On Sun, Jan 24, 2016 at 1:54 PM, Ralph Goers <
>>>>>>> ralph.goers@dslextreme.com> wrote:
>>>>>>>
>>>>>>>> Yes, Shutdownable is too weird.
>>>>>>>>
>>>>>>>
>>>>>>> How about calling it simply "Shutdown" then? FooCapable feels weird
>>>>>>> to me.
>>>>>>>
>>>>>>> Can anyone think of other (one-method or not) optional feature-like
>>>>>>> interfaces in the JRE or other code base?
>>>>>>>
>>>>>>
>>>>>> hm... ShutdownService?
>>>>>>
>>>>>> Gary
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> Gary
>>>>>>>
>>>>>>> Closeable would imply there is a close method, not a shutdown
>>>>>>>> method.  I have my doubts about the try-with-resources use case here.
>>>>>>>> Virtually all usages are probably going to be to disable automatic shutdown
>>>>>>>> and then the user placing the shutdown call somewhere they can control,
>>>>>>>> which probably will have nothing to do with initialization of logging.
>>>>>>>>
>>>>>>>> Ralph
>>>>>>>>
>>>>>>>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <ga...@gmail.com>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Resending, got a error from my phone...
>>>>>>>> ---------- Forwarded message ----------
>>>>>>>> From: "Gary Gregory" <ga...@gmail.com>
>>>>>>>> Date: Jan 24, 2016 1:41 PM
>>>>>>>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown
>>>>>>>> methods to LogManager
>>>>>>>> To: <de...@logging.apache.org>
>>>>>>>> Cc:
>>>>>>>>
>>>>>>>> Hi all,
>>>>>>>>
>>>>>>>> Any reason not use the usual -able postfix instead of
>>>>>>>> ShutdownCapable: Shutdownable sounds too weird? What about reusing plain
>>>>>>>> old Closeable? That means you could use the context in a try-with-resources
>>>>>>>> block, a bonus.
>>>>>>>>
>>>>>>>> Gary
>>>>>>>> On Jan 24, 2016 10:18 AM, <rg...@apache.org> wrote:
>>>>>>>>
>>>>>>>>> Repository: logging-log4j2
>>>>>>>>> Updated Branches:
>>>>>>>>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> LOG4J2-124 - Add shutdown methods to LogManager
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Project:
>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>>>>>>>> Commit:
>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7
>>>>>>>>> Tree:
>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7
>>>>>>>>> Diff:
>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7
>>>>>>>>>
>>>>>>>>> Branch: refs/heads/master
>>>>>>>>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>>>>>>>>> Parents: 7d3aac4
>>>>>>>>> Author: Ralph Goers <rg...@nextiva.com>
>>>>>>>>> Authored: Sun Jan 24 11:18:41 2016 -0700
>>>>>>>>> Committer: Ralph Goers <rg...@nextiva.com>
>>>>>>>>> Committed: Sun Jan 24 11:18:41 2016 -0700
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>  .../org/apache/logging/log4j/LogManager.java    | 62
>>>>>>>>> ++++++++++++++++++++
>>>>>>>>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>>>>>>>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>>>>>>>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>>>>>>>>  4 files changed, 93 insertions(+), 1 deletion(-)
>>>>>>>>>
>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>>
>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>> diff --git
>>>>>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>> index f10e5a8..64c6ee5 100644
>>>>>>>>> ---
>>>>>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>> +++
>>>>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>> @@ -27,6 +27,7 @@ import
>>>>>>>>> org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContext;
>>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>>>>>  import org.apache.logging.log4j.spi.Provider;
>>>>>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>>>>>  import org.apache.logging.log4j.status.StatusLogger;
>>>>>>>>>  import org.apache.logging.log4j.util.LoaderUtil;
>>>>>>>>>  import org.apache.logging.log4j.util.PropertiesUtil;
>>>>>>>>> @@ -285,6 +286,67 @@ public class LogManager {
>>>>>>>>>      }
>>>>>>>>>
>>>>>>>>>      /**
>>>>>>>>> +     * Shutdown using the default LoggerContext.
>>>>>>>>> +     * @since 2.6
>>>>>>>>> +     */
>>>>>>>>> +    public static void shutdown() {
>>>>>>>>> +        shutdown(getContext());
>>>>>>>>> +    }
>>>>>>>>> +
>>>>>>>>> +    /**
>>>>>>>>> +     * Shutdown the logging system if the logging system supports
>>>>>>>>> it.
>>>>>>>>> +     * @param currentContext if true the LoggerContext for the
>>>>>>>>> caller of this method will be used.
>>>>>>>>> +     * @since 2.6
>>>>>>>>> +     */
>>>>>>>>> +    public static void shutdown(boolean currentContext) {
>>>>>>>>> +        shutdown(getContext(currentContext));
>>>>>>>>> +    }
>>>>>>>>> +
>>>>>>>>> +    /**
>>>>>>>>> +     * Shutdown the logging system if the logging system supports
>>>>>>>>> it.
>>>>>>>>> +     * @param loader The ClassLoader for the context. If null the
>>>>>>>>> context will attempt to determine the appropriate
>>>>>>>>> +     *            ClassLoader.
>>>>>>>>> +     * @param currentContext if false the LoggerContext
>>>>>>>>> appropriate for the caller of this method will be used.
>>>>>>>>> +     * @since 2.6
>>>>>>>>> +     */
>>>>>>>>> +    public static void shutdown(final ClassLoader loader, final
>>>>>>>>> boolean currentContext) {
>>>>>>>>> +        shutdown(getContext(loader, currentContext));
>>>>>>>>> +    }
>>>>>>>>> +
>>>>>>>>> +    /**
>>>>>>>>> +     * Shutdown the logging system if the logging system supports
>>>>>>>>> it.
>>>>>>>>> +     * @param context the LoggerContext.
>>>>>>>>> +     * @since 2.6
>>>>>>>>> +     */
>>>>>>>>> +    public static void shutdown(LoggerContext context) {
>>>>>>>>> +        if (context != null && context instanceof
>>>>>>>>> ShutdownCapable) {
>>>>>>>>> +            ((ShutdownCapable) context).shutdown();
>>>>>>>>> +        }
>>>>>>>>> +    }
>>>>>>>>> +
>>>>>>>>> +    /**
>>>>>>>>> +     * Shutdown the logging system if the logging system supports
>>>>>>>>> it.
>>>>>>>>> +     * @param fqcn The fully qualified class name of the Class
>>>>>>>>> that this method is a member of.
>>>>>>>>> +     * @param currentContext if false the LoggerContext
>>>>>>>>> appropriate for the caller of this method will be used.
>>>>>>>>> +     * @since 2.6
>>>>>>>>> +     */
>>>>>>>>> +    protected static void shutdown(final String fqcn, final
>>>>>>>>> boolean currentContext) {
>>>>>>>>> +        shutdown(getContext(fqcn, currentContext));
>>>>>>>>> +    }
>>>>>>>>> +
>>>>>>>>> +    /**
>>>>>>>>> +     * Shutdown the logging system if the logging system supports
>>>>>>>>> it.
>>>>>>>>> +     * @param fqcn The fully qualified class name of the Class
>>>>>>>>> that this method is a member of.
>>>>>>>>> +     * @param loader The ClassLoader for the context. If null the
>>>>>>>>> context will attempt to determine the appropriate
>>>>>>>>> +     *            ClassLoader.
>>>>>>>>> +     * @param currentContext if false the LoggerContext
>>>>>>>>> appropriate for the caller of this method will be used.
>>>>>>>>> +     * @since 2.6
>>>>>>>>> +     */
>>>>>>>>> +    protected static void shutdown(final String fqcn, final
>>>>>>>>> ClassLoader loader, final boolean currentContext) {
>>>>>>>>> +        shutdown(getContext(fqcn, loader, currentContext));
>>>>>>>>> +    }
>>>>>>>>> +
>>>>>>>>> +    /**
>>>>>>>>>       * Returns the current LoggerContextFactory.
>>>>>>>>>       *
>>>>>>>>>       * @return The LoggerContextFactory.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>>>
>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>> diff --git
>>>>>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>>> new file mode 100644
>>>>>>>>> index 0000000..a46ef60
>>>>>>>>> --- /dev/null
>>>>>>>>> +++
>>>>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>>> @@ -0,0 +1,17 @@
>>>>>>>>> +/*
>>>>>>>>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>>>>>>>>> + * All rights reserved.
>>>>>>>>> + */
>>>>>>>>> +package org.apache.logging.log4j.spi;
>>>>>>>>> +
>>>>>>>>> +/**
>>>>>>>>> + * Interface to be implemented by LoggerContext's that provide a
>>>>>>>>> shutdown method.
>>>>>>>>> + * @since 2.6
>>>>>>>>> + */
>>>>>>>>> +public interface ShutdownCapable {
>>>>>>>>> +
>>>>>>>>> +    /**
>>>>>>>>> +     * Requests that the logging implementation shut down.
>>>>>>>>> +     */
>>>>>>>>> +    void shutdown();
>>>>>>>>> +}
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>>
>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>> diff --git
>>>>>>>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>> index 48f0eea..596a9f2 100644
>>>>>>>>> ---
>>>>>>>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>> +++
>>>>>>>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>> @@ -17,6 +17,7 @@
>>>>>>>>>  package org.apache.logging.log4j;
>>>>>>>>>
>>>>>>>>>  import
>>>>>>>>> org.apache.logging.log4j.message.ParameterizedMessageFactory;
>>>>>>>>> +import org.apache.logging.log4j.spi.LoggerContext;
>>>>>>>>>  import org.junit.Test;
>>>>>>>>>
>>>>>>>>>  import static org.junit.Assert.*;
>>>>>>>>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>>>>>>>>          assertNotNull("No Logger returned", logger);
>>>>>>>>>          assertTrue("Incorrect Logger name: " +
>>>>>>>>> logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>>>>>>>>      }
>>>>>>>>> +
>>>>>>>>> +    @Test
>>>>>>>>> +    public void testShutdown() {
>>>>>>>>> +        LoggerContext loggerContext =
>>>>>>>>> LogManager.getContext(false);
>>>>>>>>> +        LogManager.shutdown(loggerContext);
>>>>>>>>> +    }
>>>>>>>>>  }
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>>
>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>> diff --git
>>>>>>>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>> index 42efbb5..fcdfc16 100644
>>>>>>>>> ---
>>>>>>>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>> +++
>>>>>>>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>> @@ -45,6 +45,7 @@ import
>>>>>>>>> org.apache.logging.log4j.message.MessageFactory;
>>>>>>>>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>>>>>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>>>>>
>>>>>>>>>  import static
>>>>>>>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>>>>>
>>>>>>>>> @@ -54,7 +55,7 @@ import static
>>>>>>>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>>>>>   * filters, etc and will be atomically updated whenever a
>>>>>>>>> reconfigure occurs.
>>>>>>>>>   */
>>>>>>>>>  public class LoggerContext extends AbstractLifeCycle implements
>>>>>>>>> org.apache.logging.log4j.spi.LoggerContext,
>>>>>>>>> -        ConfigurationListener {
>>>>>>>>> +        ShutdownCapable, ConfigurationListener {
>>>>>>>>>
>>>>>>>>>      /**
>>>>>>>>>       * Property name of the property change event fired if the
>>>>>>>>> configuration is changed.
>>>>>>>>> @@ -278,6 +279,11 @@ public class LoggerContext extends
>>>>>>>>> AbstractLifeCycle implements org.apache.loggi
>>>>>>>>>      }
>>>>>>>>>
>>>>>>>>>      @Override
>>>>>>>>> +    public void shutdown() {
>>>>>>>>> +        stop();
>>>>>>>>> +    }
>>>>>>>>> +
>>>>>>>>> +    @Override
>>>>>>>>>      public void stop() {
>>>>>>>>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...",
>>>>>>>>> getName(), this);
>>>>>>>>>          configLock.lock();
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>>>>> <gg...@apache.org>
>>>>>>> Java Persistence with Hibernate, Second Edition
>>>>>>> <http://www.manning.com/bauer3/>
>>>>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>>>>> Blog: http://garygregory.wordpress.com
>>>>>>> Home: http://garygregory.com/
>>>>>>> Tweet! http://twitter.com/GaryGregory
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>>>> <gg...@apache.org>
>>>>>> Java Persistence with Hibernate, Second Edition
>>>>>> <http://www.manning.com/bauer3/>
>>>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>>>> Blog: http://garygregory.wordpress.com
>>>>>> Home: http://garygregory.com/
>>>>>> Tweet! http://twitter.com/GaryGregory
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>>> <gg...@apache.org>
>>>>> Java Persistence with Hibernate, Second Edition
>>>>> <http://www.manning.com/bauer3/>
>>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>>> Blog: http://garygregory.wordpress.com
>>>>> Home: http://garygregory.com/
>>>>> Tweet! http://twitter.com/GaryGregory
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Matt Sicker <bo...@gmail.com>
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Matt Sicker <bo...@gmail.com>
>>>
>>
>>
>>
>> --
>> [image: MagineTV]
>>
>> *Mikael Ståldal*
>> Senior software developer
>>
>> *Magine TV*
>> mikael.staldal@magine.com
>> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>> <http://www.magine.com/>
>>
>> Privileged and/or Confidential Information may be contained in this
>> message. If you are not the addressee indicated in this message
>> (or responsible for delivery of the message to such a person), you may
>> not copy or deliver this message to anyone. In such case,
>> you should destroy this message and kindly notify the sender by reply
>> email.
>>
>
>
>
> --
> Matt Sicker <bo...@gmail.com>
>
>
>


-- 
Matt Sicker <bo...@gmail.com>

Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Ralph Goers <ra...@dslextreme.com>.
I’m not sure what you mean Matt. It currently is synchronous as we don’t delegate the work to another thread - we directly call the LoggerContext which loops through and shuts down all the various components. IMO, making it asynchronous would be problematic as there would be no way to guarantee that the shutdown actually completed before the JVM terminated.

Ralph

> On Jan 26, 2016, at 8:38 AM, Matt Sicker <bo...@gmail.com> wrote:
> 
> Shutdown sounds like an execute once thing, so I don't see why it would need to be synchronous.
> 
> On 26 January 2016 at 03:15, Mikael Ståldal <mikael.staldal@magine.com <ma...@magine.com>> wrote:
> I think that we should be clear, in Javadoc, about whether this new method is synchronous/blocking or not.
> 
> (I could say the same about quite a few existing methods as well, but let's at least start to be clear about new methods from now.)
> 
> On Tue, Jan 26, 2016 at 1:31 AM, Matt Sicker <boards@gmail.com <ma...@gmail.com>> wrote:
> I like it!
> 
> On 25 January 2016 at 18:23, Ralph Goers <ralph.goers@dslextreme.com <ma...@dslextreme.com>> wrote:
> Then the method name would be terminate?  I could live with that.  I also like the fact that when something goes wrong with it then it would be interminable ;-)
> 
> Ralph
> 
>> On Jan 25, 2016, at 5:18 PM, Matt Sicker <boards@gmail.com <ma...@gmail.com>> wrote:
>> 
>> How about Terminable? It's even a real word to boot.
>> 
>> On 25 January 2016 at 18:15, Ralph Goers <ralph.goers@dslextreme.com <ma...@dslextreme.com>> wrote:
>> Yes, well - Serializable actually sounds like it should be a real word. Shutdownable doesn’t - in fact, my mail editor just split it into two words to “help” me. I take a different view. A class that declares it implements an interface isn’t “capable” of anything - it just implements the interface. The interface name is what tells you that the implementing class is able to do something, which is why you have Comparable instead of just Compare, Cloneable instead of just Clone,  or Closeable instead of just Close. Would you want Stop instead of Stoppable?  I view “able” as just a shorthand way of saying “Capable”, but unfortunately that just doesn’t sound right with Shutdown (at least to me).
>> 
>> Here are some “able” alternatives - presumably each would have a corresponding method name instead of shutdown:
>> Terminateable.
>> Completeable.
>> Concludeable.
>> Haltable.
>> Dismissable.
>> Expireable.
>> 
>> I suppose we could also use Stoppable but that seems odd since stop is part of Lifecycle.
>> 
>> Got a preference?
>> 
>> Ralph
>> 
>> 
>> 
>>> On Jan 25, 2016, at 4:35 PM, Gary Gregory <garydgregory@gmail.com <ma...@gmail.com>> wrote:
>>> 
>>> I see some interfaces with "*Capable*" in the name here and there in the FOSS world (but not in the JRE) so I am a little more comfortable with it. 
>>> 
>>> I still see plain old "Shutdown" as simpler. 
>>> 
>>> I think I've boiled down my feel for this name to the fact that the Capable postfix is redundant since a class implementing any interface is "capable" of that functionality. IOW we have Serializable vs. SerializationCabable, which means the same thing.
>>> 
>>> Gary
>>> 
>>> On Mon, Jan 25, 2016 at 7:27 AM, Ralph Goers <ralph.goers@dslextreme.com <ma...@dslextreme.com>> wrote:
>>> What does it feel weird to you?  To be honest, I originally named the interface ‘Shutdown” and then changed it since it really is about implementing a behavior and “Shutdown” alone doesn’t really describe that.
>>> 
>>> Ralph
>>> 
>>>> On Jan 24, 2016, at 11:09 PM, Gary Gregory <garydgregory@gmail.com <ma...@gmail.com>> wrote:
>>>> 
>>>> On Sun, Jan 24, 2016 at 10:07 PM, Gary Gregory <garydgregory@gmail.com <ma...@gmail.com>> wrote:
>>>> On Sun, Jan 24, 2016 at 1:54 PM, Ralph Goers <ralph.goers@dslextreme.com <ma...@dslextreme.com>> wrote:
>>>> Yes, Shutdownable is too weird. 
>>>> 
>>>> How about calling it simply "Shutdown" then? FooCapable feels weird to me.
>>>> 
>>>> Can anyone think of other (one-method or not) optional feature-like interfaces in the JRE or other code base?
>>>> 
>>>> hm... ShutdownService?
>>>> 
>>>> Gary
>>>>  
>>>> 
>>>> Gary
>>>> 
>>>> Closeable would imply there is a close method, not a shutdown method.  I have my doubts about the try-with-resources use case here.  Virtually all usages are probably going to be to disable automatic shutdown and then the user placing the shutdown call somewhere they can control, which probably will have nothing to do with initialization of logging. 
>>>> 
>>>> Ralph
>>>> 
>>>>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <garydgregory@gmail.com <ma...@gmail.com>> wrote:
>>>>> 
>>>>> Resending, got a error from my phone...
>>>>> 
>>>>> ---------- Forwarded message ----------
>>>>> From: "Gary Gregory" <garydgregory@gmail.com <ma...@gmail.com>>
>>>>> Date: Jan 24, 2016 1:41 PM
>>>>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager
>>>>> To: <dev@logging.apache.org <ma...@logging.apache.org>>
>>>>> Cc: 
>>>>> 
>>>>> Hi all,
>>>>> 
>>>>> Any reason not use the usual -able postfix instead of ShutdownCapable: Shutdownable sounds too weird? What about reusing plain old Closeable? That means you could use the context in a try-with-resources block, a bonus.
>>>>> 
>>>>> Gary 
>>>>> 
>>>>> On Jan 24, 2016 10:18 AM, <rgoers@apache.org <ma...@apache.org>> wrote:
>>>>> Repository: logging-log4j2
>>>>> Updated Branches:
>>>>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>>>>> 
>>>>> 
>>>>> LOG4J2-124 - Add shutdown methods to LogManager
>>>>> 
>>>>> 
>>>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo <http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo>
>>>>> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7>
>>>>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7>
>>>>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7>
>>>>> 
>>>>> Branch: refs/heads/master
>>>>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>>>>> Parents: 7d3aac4
>>>>> Author: Ralph Goers <rgoers@nextiva.com <ma...@nextiva.com>>
>>>>> Authored: Sun Jan 24 11:18:41 2016 -0700
>>>>> Committer: Ralph Goers <rgoers@nextiva.com <ma...@nextiva.com>>
>>>>> Committed: Sun Jan 24 11:18:41 2016 -0700
>>>>> 
>>>>> ----------------------------------------------------------------------
>>>>>  .../org/apache/logging/log4j/LogManager.java    | 62 ++++++++++++++++++++
>>>>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>>>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>>>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>>>>  4 files changed, 93 insertions(+), 1 deletion(-)
>>>>> ----------------------------------------------------------------------
>>>>> 
>>>>> 
>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java>
>>>>> ----------------------------------------------------------------------
>>>>> diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>> index f10e5a8..64c6ee5 100644
>>>>> --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>> @@ -27,6 +27,7 @@ import org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>>>>  import org.apache.logging.log4j.spi.LoggerContext;
>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>  import org.apache.logging.log4j.spi.Provider;
>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>  import org.apache.logging.log4j.status.StatusLogger;
>>>>>  import org.apache.logging.log4j.util.LoaderUtil;
>>>>>  import org.apache.logging.log4j.util.PropertiesUtil;
>>>>> @@ -285,6 +286,67 @@ public class LogManager {
>>>>>      }
>>>>> 
>>>>>      /**
>>>>> +     * Shutdown using the default LoggerContext.
>>>>> +     * @since 2.6
>>>>> +     */
>>>>> +    public static void shutdown() {
>>>>> +        shutdown(getContext());
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>> +     * @param currentContext if true the LoggerContext for the caller of this method will be used.
>>>>> +     * @since 2.6
>>>>> +     */
>>>>> +    public static void shutdown(boolean currentContext) {
>>>>> +        shutdown(getContext(currentContext));
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>> +     * @param loader The ClassLoader for the context. If null the context will attempt to determine the appropriate
>>>>> +     *            ClassLoader.
>>>>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>>>>> +     * @since 2.6
>>>>> +     */
>>>>> +    public static void shutdown(final ClassLoader loader, final boolean currentContext) {
>>>>> +        shutdown(getContext(loader, currentContext));
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>> +     * @param context the LoggerContext.
>>>>> +     * @since 2.6
>>>>> +     */
>>>>> +    public static void shutdown(LoggerContext context) {
>>>>> +        if (context != null && context instanceof ShutdownCapable) {
>>>>> +            ((ShutdownCapable) context).shutdown();
>>>>> +        }
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>> +     * @param fqcn The fully qualified class name of the Class that this method is a member of.
>>>>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>>>>> +     * @since 2.6
>>>>> +     */
>>>>> +    protected static void shutdown(final String fqcn, final boolean currentContext) {
>>>>> +        shutdown(getContext(fqcn, currentContext));
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>> +     * @param fqcn The fully qualified class name of the Class that this method is a member of.
>>>>> +     * @param loader The ClassLoader for the context. If null the context will attempt to determine the appropriate
>>>>> +     *            ClassLoader.
>>>>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>>>>> +     * @since 2.6
>>>>> +     */
>>>>> +    protected static void shutdown(final String fqcn, final ClassLoader loader, final boolean currentContext) {
>>>>> +        shutdown(getContext(fqcn, loader, currentContext));
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>>       * Returns the current LoggerContextFactory.
>>>>>       *
>>>>>       * @return The LoggerContextFactory.
>>>>> 
>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java>
>>>>> ----------------------------------------------------------------------
>>>>> diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>> new file mode 100644
>>>>> index 0000000..a46ef60
>>>>> --- /dev/null
>>>>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>> @@ -0,0 +1,17 @@
>>>>> +/*
>>>>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>>>>> + * All rights reserved.
>>>>> + */
>>>>> +package org.apache.logging.log4j.spi;
>>>>> +
>>>>> +/**
>>>>> + * Interface to be implemented by LoggerContext's that provide a shutdown method.
>>>>> + * @since 2.6
>>>>> + */
>>>>> +public interface ShutdownCapable {
>>>>> +
>>>>> +    /**
>>>>> +     * Requests that the logging implementation shut down.
>>>>> +     */
>>>>> +    void shutdown();
>>>>> +}
>>>>> 
>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java>
>>>>> ----------------------------------------------------------------------
>>>>> diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>> index 48f0eea..596a9f2 100644
>>>>> --- a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>> +++ b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>> @@ -17,6 +17,7 @@
>>>>>  package org.apache.logging.log4j;
>>>>> 
>>>>>  import org.apache.logging.log4j.message.ParameterizedMessageFactory;
>>>>> +import org.apache.logging.log4j.spi.LoggerContext;
>>>>>  import org.junit.Test;
>>>>> 
>>>>>  import static org.junit.Assert.*;
>>>>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>>>>          assertNotNull("No Logger returned", logger);
>>>>>          assertTrue("Incorrect Logger name: " + logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>>>>      }
>>>>> +
>>>>> +    @Test
>>>>> +    public void testShutdown() {
>>>>> +        LoggerContext loggerContext = LogManager.getContext(false);
>>>>> +        LogManager.shutdown(loggerContext);
>>>>> +    }
>>>>>  }
>>>>> 
>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java>
>>>>> ----------------------------------------------------------------------
>>>>> diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>> index 42efbb5..fcdfc16 100644
>>>>> --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>> +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>> @@ -45,6 +45,7 @@ import org.apache.logging.log4j.message.MessageFactory;
>>>>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>> 
>>>>>  import static org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>> 
>>>>> @@ -54,7 +55,7 @@ import static org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>   * filters, etc and will be atomically updated whenever a reconfigure occurs.
>>>>>   */
>>>>>  public class LoggerContext extends AbstractLifeCycle implements org.apache.logging.log4j.spi.LoggerContext,
>>>>> -        ConfigurationListener {
>>>>> +        ShutdownCapable, ConfigurationListener {
>>>>> 
>>>>>      /**
>>>>>       * Property name of the property change event fired if the configuration is changed.
>>>>> @@ -278,6 +279,11 @@ public class LoggerContext extends AbstractLifeCycle implements org.apache.loggi
>>>>>      }
>>>>> 
>>>>>      @Override
>>>>> +    public void shutdown() {
>>>>> +        stop();
>>>>> +    }
>>>>> +
>>>>> +    @Override
>>>>>      public void stop() {
>>>>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...", getName(), this);
>>>>>          configLock.lock();
>>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> -- 
>>>> E-Mail: garydgregory@gmail.com <ma...@gmail.com> | ggregory@apache.org  <ma...@apache.org>
>>>> Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/>
>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>> Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> 
>>>> Home: http://garygregory.com/ <http://garygregory.com/>
>>>> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>
>>>> 
>>>> 
>>>> -- 
>>>> E-Mail: garydgregory@gmail.com <ma...@gmail.com> | ggregory@apache.org  <ma...@apache.org>
>>>> Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/>
>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>> Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> 
>>>> Home: http://garygregory.com/ <http://garygregory.com/>
>>>> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>
>>> 
>>> 
>>> 
>>> -- 
>>> E-Mail: garydgregory@gmail.com <ma...@gmail.com> | ggregory@apache.org  <ma...@apache.org>
>>> Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/>
>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>> Spring Batch in Action <http://www.manning.com/templier/>
>>> Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> 
>>> Home: http://garygregory.com/ <http://garygregory.com/>
>>> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>
>> 
>> 
>> 
>> -- 
>> Matt Sicker <boards@gmail.com <ma...@gmail.com>>
> 
> 
> 
> 
> -- 
> Matt Sicker <boards@gmail.com <ma...@gmail.com>>
> 
> 
> 
> -- 
>  
> 
> Mikael Ståldal
> Senior software developer 
> 
> Magine TV
> mikael.staldal@magine.com <ma...@magine.com>    
> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com  <http://www.magine.com/>
> 
> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case, 
> you should destroy this message and kindly notify the sender by reply email.   
> 
> 
> 
> -- 
> Matt Sicker <boards@gmail.com <ma...@gmail.com>>


Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Matt Sicker <bo...@gmail.com>.
Shutdown sounds like an execute once thing, so I don't see why it would
need to be synchronous.

On 26 January 2016 at 03:15, Mikael Ståldal <mi...@magine.com>
wrote:

> I think that we should be clear, in Javadoc, about whether this new method
> is synchronous/blocking or not.
>
> (I could say the same about quite a few existing methods as well, but
> let's at least start to be clear about new methods from now.)
>
> On Tue, Jan 26, 2016 at 1:31 AM, Matt Sicker <bo...@gmail.com> wrote:
>
>> I like it!
>>
>> On 25 January 2016 at 18:23, Ralph Goers <ra...@dslextreme.com>
>> wrote:
>>
>>> Then the method name would be terminate?  I could live with that.  I
>>> also like the fact that when something goes wrong with it then it would be
>>> interminable ;-)
>>>
>>> Ralph
>>>
>>> On Jan 25, 2016, at 5:18 PM, Matt Sicker <bo...@gmail.com> wrote:
>>>
>>> How about Terminable? It's even a real word to boot.
>>>
>>> On 25 January 2016 at 18:15, Ralph Goers <ra...@dslextreme.com>
>>> wrote:
>>>
>>>> Yes, well - Serializable actually sounds like it should be a real word.
>>>> Shutdownable doesn’t - in fact, my mail editor just split it into two words
>>>> to “help” me. I take a different view. A class that declares it implements
>>>> an interface isn’t “capable” of anything - it just implements the
>>>> interface. The interface name is what tells you that the implementing class
>>>> is able to do something, which is why you have Comparable instead of just
>>>> Compare, Cloneable instead of just Clone,  or Closeable instead of just
>>>> Close. Would you want Stop instead of Stoppable?  I view “able” as just a
>>>> shorthand way of saying “Capable”, but unfortunately that just doesn’t
>>>> sound right with Shutdown (at least to me).
>>>>
>>>> Here are some “able” alternatives - presumably each would have a
>>>> corresponding method name instead of shutdown:
>>>> Terminateable.
>>>> Completeable.
>>>> Concludeable.
>>>> Haltable.
>>>> Dismissable.
>>>> Expireable.
>>>>
>>>> I suppose we could also use Stoppable but that seems odd since stop is
>>>> part of Lifecycle.
>>>>
>>>> Got a preference?
>>>>
>>>> Ralph
>>>>
>>>>
>>>>
>>>> On Jan 25, 2016, at 4:35 PM, Gary Gregory <ga...@gmail.com>
>>>> wrote:
>>>>
>>>> I see some interfaces with "*Capable*" in the name here and there in
>>>> the FOSS world (but not in the JRE) so I am a little more comfortable with
>>>> it.
>>>>
>>>> I still see plain old "Shutdown" as simpler.
>>>>
>>>> I think I've boiled down my feel for this name to the fact that the
>>>> Capable postfix is redundant since a class implementing any interface is
>>>> "capable" of that functionality. IOW we have Serializable vs.
>>>> SerializationCabable, which means the same thing.
>>>>
>>>> Gary
>>>>
>>>> On Mon, Jan 25, 2016 at 7:27 AM, Ralph Goers <
>>>> ralph.goers@dslextreme.com> wrote:
>>>>
>>>>> What does it feel weird to you?  To be honest, I originally named the
>>>>> interface ‘Shutdown” and then changed it since it really is about
>>>>> implementing a behavior and “Shutdown” alone doesn’t really describe that.
>>>>>
>>>>> Ralph
>>>>>
>>>>> On Jan 24, 2016, at 11:09 PM, Gary Gregory <ga...@gmail.com>
>>>>> wrote:
>>>>>
>>>>> On Sun, Jan 24, 2016 at 10:07 PM, Gary Gregory <garydgregory@gmail.com
>>>>> > wrote:
>>>>>
>>>>>> On Sun, Jan 24, 2016 at 1:54 PM, Ralph Goers <
>>>>>> ralph.goers@dslextreme.com> wrote:
>>>>>>
>>>>>>> Yes, Shutdownable is too weird.
>>>>>>>
>>>>>>
>>>>>> How about calling it simply "Shutdown" then? FooCapable feels weird
>>>>>> to me.
>>>>>>
>>>>>> Can anyone think of other (one-method or not) optional feature-like
>>>>>> interfaces in the JRE or other code base?
>>>>>>
>>>>>
>>>>> hm... ShutdownService?
>>>>>
>>>>> Gary
>>>>>
>>>>>
>>>>>>
>>>>>> Gary
>>>>>>
>>>>>> Closeable would imply there is a close method, not a shutdown
>>>>>>> method.  I have my doubts about the try-with-resources use case here.
>>>>>>> Virtually all usages are probably going to be to disable automatic shutdown
>>>>>>> and then the user placing the shutdown call somewhere they can control,
>>>>>>> which probably will have nothing to do with initialization of logging.
>>>>>>>
>>>>>>> Ralph
>>>>>>>
>>>>>>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <ga...@gmail.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>> Resending, got a error from my phone...
>>>>>>> ---------- Forwarded message ----------
>>>>>>> From: "Gary Gregory" <ga...@gmail.com>
>>>>>>> Date: Jan 24, 2016 1:41 PM
>>>>>>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown
>>>>>>> methods to LogManager
>>>>>>> To: <de...@logging.apache.org>
>>>>>>> Cc:
>>>>>>>
>>>>>>> Hi all,
>>>>>>>
>>>>>>> Any reason not use the usual -able postfix instead of
>>>>>>> ShutdownCapable: Shutdownable sounds too weird? What about reusing plain
>>>>>>> old Closeable? That means you could use the context in a try-with-resources
>>>>>>> block, a bonus.
>>>>>>>
>>>>>>> Gary
>>>>>>> On Jan 24, 2016 10:18 AM, <rg...@apache.org> wrote:
>>>>>>>
>>>>>>>> Repository: logging-log4j2
>>>>>>>> Updated Branches:
>>>>>>>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>>>>>>>>
>>>>>>>>
>>>>>>>> LOG4J2-124 - Add shutdown methods to LogManager
>>>>>>>>
>>>>>>>>
>>>>>>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>>>>>>> Commit:
>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7
>>>>>>>> Tree:
>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7
>>>>>>>> Diff:
>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7
>>>>>>>>
>>>>>>>> Branch: refs/heads/master
>>>>>>>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>>>>>>>> Parents: 7d3aac4
>>>>>>>> Author: Ralph Goers <rg...@nextiva.com>
>>>>>>>> Authored: Sun Jan 24 11:18:41 2016 -0700
>>>>>>>> Committer: Ralph Goers <rg...@nextiva.com>
>>>>>>>> Committed: Sun Jan 24 11:18:41 2016 -0700
>>>>>>>>
>>>>>>>>
>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>  .../org/apache/logging/log4j/LogManager.java    | 62
>>>>>>>> ++++++++++++++++++++
>>>>>>>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>>>>>>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>>>>>>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>>>>>>>  4 files changed, 93 insertions(+), 1 deletion(-)
>>>>>>>>
>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>>
>>>>>>>> ----------------------------------------------------------------------
>>>>>>>> diff --git
>>>>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>> index f10e5a8..64c6ee5 100644
>>>>>>>> ---
>>>>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>> +++
>>>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>> @@ -27,6 +27,7 @@ import
>>>>>>>> org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContext;
>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>>>>  import org.apache.logging.log4j.spi.Provider;
>>>>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>>>>  import org.apache.logging.log4j.status.StatusLogger;
>>>>>>>>  import org.apache.logging.log4j.util.LoaderUtil;
>>>>>>>>  import org.apache.logging.log4j.util.PropertiesUtil;
>>>>>>>> @@ -285,6 +286,67 @@ public class LogManager {
>>>>>>>>      }
>>>>>>>>
>>>>>>>>      /**
>>>>>>>> +     * Shutdown using the default LoggerContext.
>>>>>>>> +     * @since 2.6
>>>>>>>> +     */
>>>>>>>> +    public static void shutdown() {
>>>>>>>> +        shutdown(getContext());
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>> +    /**
>>>>>>>> +     * Shutdown the logging system if the logging system supports
>>>>>>>> it.
>>>>>>>> +     * @param currentContext if true the LoggerContext for the
>>>>>>>> caller of this method will be used.
>>>>>>>> +     * @since 2.6
>>>>>>>> +     */
>>>>>>>> +    public static void shutdown(boolean currentContext) {
>>>>>>>> +        shutdown(getContext(currentContext));
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>> +    /**
>>>>>>>> +     * Shutdown the logging system if the logging system supports
>>>>>>>> it.
>>>>>>>> +     * @param loader The ClassLoader for the context. If null the
>>>>>>>> context will attempt to determine the appropriate
>>>>>>>> +     *            ClassLoader.
>>>>>>>> +     * @param currentContext if false the LoggerContext
>>>>>>>> appropriate for the caller of this method will be used.
>>>>>>>> +     * @since 2.6
>>>>>>>> +     */
>>>>>>>> +    public static void shutdown(final ClassLoader loader, final
>>>>>>>> boolean currentContext) {
>>>>>>>> +        shutdown(getContext(loader, currentContext));
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>> +    /**
>>>>>>>> +     * Shutdown the logging system if the logging system supports
>>>>>>>> it.
>>>>>>>> +     * @param context the LoggerContext.
>>>>>>>> +     * @since 2.6
>>>>>>>> +     */
>>>>>>>> +    public static void shutdown(LoggerContext context) {
>>>>>>>> +        if (context != null && context instanceof ShutdownCapable)
>>>>>>>> {
>>>>>>>> +            ((ShutdownCapable) context).shutdown();
>>>>>>>> +        }
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>> +    /**
>>>>>>>> +     * Shutdown the logging system if the logging system supports
>>>>>>>> it.
>>>>>>>> +     * @param fqcn The fully qualified class name of the Class
>>>>>>>> that this method is a member of.
>>>>>>>> +     * @param currentContext if false the LoggerContext
>>>>>>>> appropriate for the caller of this method will be used.
>>>>>>>> +     * @since 2.6
>>>>>>>> +     */
>>>>>>>> +    protected static void shutdown(final String fqcn, final
>>>>>>>> boolean currentContext) {
>>>>>>>> +        shutdown(getContext(fqcn, currentContext));
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>> +    /**
>>>>>>>> +     * Shutdown the logging system if the logging system supports
>>>>>>>> it.
>>>>>>>> +     * @param fqcn The fully qualified class name of the Class
>>>>>>>> that this method is a member of.
>>>>>>>> +     * @param loader The ClassLoader for the context. If null the
>>>>>>>> context will attempt to determine the appropriate
>>>>>>>> +     *            ClassLoader.
>>>>>>>> +     * @param currentContext if false the LoggerContext
>>>>>>>> appropriate for the caller of this method will be used.
>>>>>>>> +     * @since 2.6
>>>>>>>> +     */
>>>>>>>> +    protected static void shutdown(final String fqcn, final
>>>>>>>> ClassLoader loader, final boolean currentContext) {
>>>>>>>> +        shutdown(getContext(fqcn, loader, currentContext));
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>> +    /**
>>>>>>>>       * Returns the current LoggerContextFactory.
>>>>>>>>       *
>>>>>>>>       * @return The LoggerContextFactory.
>>>>>>>>
>>>>>>>>
>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>>
>>>>>>>> ----------------------------------------------------------------------
>>>>>>>> diff --git
>>>>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>> new file mode 100644
>>>>>>>> index 0000000..a46ef60
>>>>>>>> --- /dev/null
>>>>>>>> +++
>>>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>> @@ -0,0 +1,17 @@
>>>>>>>> +/*
>>>>>>>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>>>>>>>> + * All rights reserved.
>>>>>>>> + */
>>>>>>>> +package org.apache.logging.log4j.spi;
>>>>>>>> +
>>>>>>>> +/**
>>>>>>>> + * Interface to be implemented by LoggerContext's that provide a
>>>>>>>> shutdown method.
>>>>>>>> + * @since 2.6
>>>>>>>> + */
>>>>>>>> +public interface ShutdownCapable {
>>>>>>>> +
>>>>>>>> +    /**
>>>>>>>> +     * Requests that the logging implementation shut down.
>>>>>>>> +     */
>>>>>>>> +    void shutdown();
>>>>>>>> +}
>>>>>>>>
>>>>>>>>
>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>>
>>>>>>>> ----------------------------------------------------------------------
>>>>>>>> diff --git
>>>>>>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>> index 48f0eea..596a9f2 100644
>>>>>>>> ---
>>>>>>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>> +++
>>>>>>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>> @@ -17,6 +17,7 @@
>>>>>>>>  package org.apache.logging.log4j;
>>>>>>>>
>>>>>>>>  import
>>>>>>>> org.apache.logging.log4j.message.ParameterizedMessageFactory;
>>>>>>>> +import org.apache.logging.log4j.spi.LoggerContext;
>>>>>>>>  import org.junit.Test;
>>>>>>>>
>>>>>>>>  import static org.junit.Assert.*;
>>>>>>>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>>>>>>>          assertNotNull("No Logger returned", logger);
>>>>>>>>          assertTrue("Incorrect Logger name: " +
>>>>>>>> logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>>>>>>>      }
>>>>>>>> +
>>>>>>>> +    @Test
>>>>>>>> +    public void testShutdown() {
>>>>>>>> +        LoggerContext loggerContext = LogManager.getContext(false);
>>>>>>>> +        LogManager.shutdown(loggerContext);
>>>>>>>> +    }
>>>>>>>>  }
>>>>>>>>
>>>>>>>>
>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>>
>>>>>>>> ----------------------------------------------------------------------
>>>>>>>> diff --git
>>>>>>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>> index 42efbb5..fcdfc16 100644
>>>>>>>> ---
>>>>>>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>> +++
>>>>>>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>> @@ -45,6 +45,7 @@ import
>>>>>>>> org.apache.logging.log4j.message.MessageFactory;
>>>>>>>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>>>>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>>>>
>>>>>>>>  import static
>>>>>>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>>>>
>>>>>>>> @@ -54,7 +55,7 @@ import static
>>>>>>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>>>>   * filters, etc and will be atomically updated whenever a
>>>>>>>> reconfigure occurs.
>>>>>>>>   */
>>>>>>>>  public class LoggerContext extends AbstractLifeCycle implements
>>>>>>>> org.apache.logging.log4j.spi.LoggerContext,
>>>>>>>> -        ConfigurationListener {
>>>>>>>> +        ShutdownCapable, ConfigurationListener {
>>>>>>>>
>>>>>>>>      /**
>>>>>>>>       * Property name of the property change event fired if the
>>>>>>>> configuration is changed.
>>>>>>>> @@ -278,6 +279,11 @@ public class LoggerContext extends
>>>>>>>> AbstractLifeCycle implements org.apache.loggi
>>>>>>>>      }
>>>>>>>>
>>>>>>>>      @Override
>>>>>>>> +    public void shutdown() {
>>>>>>>> +        stop();
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>> +    @Override
>>>>>>>>      public void stop() {
>>>>>>>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...",
>>>>>>>> getName(), this);
>>>>>>>>          configLock.lock();
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>>>> <gg...@apache.org>
>>>>>> Java Persistence with Hibernate, Second Edition
>>>>>> <http://www.manning.com/bauer3/>
>>>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>>>> Blog: http://garygregory.wordpress.com
>>>>>> Home: http://garygregory.com/
>>>>>> Tweet! http://twitter.com/GaryGregory
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>>> <gg...@apache.org>
>>>>> Java Persistence with Hibernate, Second Edition
>>>>> <http://www.manning.com/bauer3/>
>>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>>> Blog: http://garygregory.wordpress.com
>>>>> Home: http://garygregory.com/
>>>>> Tweet! http://twitter.com/GaryGregory
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>> Java Persistence with Hibernate, Second Edition
>>>> <http://www.manning.com/bauer3/>
>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>> Blog: http://garygregory.wordpress.com
>>>> Home: http://garygregory.com/
>>>> Tweet! http://twitter.com/GaryGregory
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Matt Sicker <bo...@gmail.com>
>>>
>>>
>>>
>>
>>
>> --
>> Matt Sicker <bo...@gmail.com>
>>
>
>
>
> --
> [image: MagineTV]
>
> *Mikael Ståldal*
> Senior software developer
>
> *Magine TV*
> mikael.staldal@magine.com
> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>
> Privileged and/or Confidential Information may be contained in this
> message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not
> copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply
> email.
>



-- 
Matt Sicker <bo...@gmail.com>

Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Mikael Ståldal <mi...@magine.com>.
I think that we should be clear, in Javadoc, about whether this new method
is synchronous/blocking or not.

(I could say the same about quite a few existing methods as well, but let's
at least start to be clear about new methods from now.)

On Tue, Jan 26, 2016 at 1:31 AM, Matt Sicker <bo...@gmail.com> wrote:

> I like it!
>
> On 25 January 2016 at 18:23, Ralph Goers <ra...@dslextreme.com>
> wrote:
>
>> Then the method name would be terminate?  I could live with that.  I also
>> like the fact that when something goes wrong with it then it would be
>> interminable ;-)
>>
>> Ralph
>>
>> On Jan 25, 2016, at 5:18 PM, Matt Sicker <bo...@gmail.com> wrote:
>>
>> How about Terminable? It's even a real word to boot.
>>
>> On 25 January 2016 at 18:15, Ralph Goers <ra...@dslextreme.com>
>> wrote:
>>
>>> Yes, well - Serializable actually sounds like it should be a real word.
>>> Shutdownable doesn’t - in fact, my mail editor just split it into two words
>>> to “help” me. I take a different view. A class that declares it implements
>>> an interface isn’t “capable” of anything - it just implements the
>>> interface. The interface name is what tells you that the implementing class
>>> is able to do something, which is why you have Comparable instead of just
>>> Compare, Cloneable instead of just Clone,  or Closeable instead of just
>>> Close. Would you want Stop instead of Stoppable?  I view “able” as just a
>>> shorthand way of saying “Capable”, but unfortunately that just doesn’t
>>> sound right with Shutdown (at least to me).
>>>
>>> Here are some “able” alternatives - presumably each would have a
>>> corresponding method name instead of shutdown:
>>> Terminateable.
>>> Completeable.
>>> Concludeable.
>>> Haltable.
>>> Dismissable.
>>> Expireable.
>>>
>>> I suppose we could also use Stoppable but that seems odd since stop is
>>> part of Lifecycle.
>>>
>>> Got a preference?
>>>
>>> Ralph
>>>
>>>
>>>
>>> On Jan 25, 2016, at 4:35 PM, Gary Gregory <ga...@gmail.com>
>>> wrote:
>>>
>>> I see some interfaces with "*Capable*" in the name here and there in the
>>> FOSS world (but not in the JRE) so I am a little more comfortable with it.
>>>
>>> I still see plain old "Shutdown" as simpler.
>>>
>>> I think I've boiled down my feel for this name to the fact that the
>>> Capable postfix is redundant since a class implementing any interface is
>>> "capable" of that functionality. IOW we have Serializable vs.
>>> SerializationCabable, which means the same thing.
>>>
>>> Gary
>>>
>>> On Mon, Jan 25, 2016 at 7:27 AM, Ralph Goers <ralph.goers@dslextreme.com
>>> > wrote:
>>>
>>>> What does it feel weird to you?  To be honest, I originally named the
>>>> interface ‘Shutdown” and then changed it since it really is about
>>>> implementing a behavior and “Shutdown” alone doesn’t really describe that.
>>>>
>>>> Ralph
>>>>
>>>> On Jan 24, 2016, at 11:09 PM, Gary Gregory <ga...@gmail.com>
>>>> wrote:
>>>>
>>>> On Sun, Jan 24, 2016 at 10:07 PM, Gary Gregory <ga...@gmail.com>
>>>>  wrote:
>>>>
>>>>> On Sun, Jan 24, 2016 at 1:54 PM, Ralph Goers <
>>>>> ralph.goers@dslextreme.com> wrote:
>>>>>
>>>>>> Yes, Shutdownable is too weird.
>>>>>>
>>>>>
>>>>> How about calling it simply "Shutdown" then? FooCapable feels weird to
>>>>> me.
>>>>>
>>>>> Can anyone think of other (one-method or not) optional feature-like
>>>>> interfaces in the JRE or other code base?
>>>>>
>>>>
>>>> hm... ShutdownService?
>>>>
>>>> Gary
>>>>
>>>>
>>>>>
>>>>> Gary
>>>>>
>>>>> Closeable would imply there is a close method, not a shutdown method.
>>>>>> I have my doubts about the try-with-resources use case here.  Virtually all
>>>>>> usages are probably going to be to disable automatic shutdown and then the
>>>>>> user placing the shutdown call somewhere they can control, which probably
>>>>>> will have nothing to do with initialization of logging.
>>>>>>
>>>>>> Ralph
>>>>>>
>>>>>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <ga...@gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>> Resending, got a error from my phone...
>>>>>> ---------- Forwarded message ----------
>>>>>> From: "Gary Gregory" <ga...@gmail.com>
>>>>>> Date: Jan 24, 2016 1:41 PM
>>>>>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown
>>>>>> methods to LogManager
>>>>>> To: <de...@logging.apache.org>
>>>>>> Cc:
>>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>> Any reason not use the usual -able postfix instead of
>>>>>> ShutdownCapable: Shutdownable sounds too weird? What about reusing plain
>>>>>> old Closeable? That means you could use the context in a try-with-resources
>>>>>> block, a bonus.
>>>>>>
>>>>>> Gary
>>>>>> On Jan 24, 2016 10:18 AM, <rg...@apache.org> wrote:
>>>>>>
>>>>>>> Repository: logging-log4j2
>>>>>>> Updated Branches:
>>>>>>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>>>>>>>
>>>>>>>
>>>>>>> LOG4J2-124 - Add shutdown methods to LogManager
>>>>>>>
>>>>>>>
>>>>>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>>>>>> Commit:
>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7
>>>>>>> Tree:
>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7
>>>>>>> Diff:
>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7
>>>>>>>
>>>>>>> Branch: refs/heads/master
>>>>>>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>>>>>>> Parents: 7d3aac4
>>>>>>> Author: Ralph Goers <rg...@nextiva.com>
>>>>>>> Authored: Sun Jan 24 11:18:41 2016 -0700
>>>>>>> Committer: Ralph Goers <rg...@nextiva.com>
>>>>>>> Committed: Sun Jan 24 11:18:41 2016 -0700
>>>>>>>
>>>>>>>
>>>>>>> ----------------------------------------------------------------------
>>>>>>>  .../org/apache/logging/log4j/LogManager.java    | 62
>>>>>>> ++++++++++++++++++++
>>>>>>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>>>>>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>>>>>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>>>>>>  4 files changed, 93 insertions(+), 1 deletion(-)
>>>>>>>
>>>>>>> ----------------------------------------------------------------------
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>>
>>>>>>> ----------------------------------------------------------------------
>>>>>>> diff --git
>>>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>> index f10e5a8..64c6ee5 100644
>>>>>>> ---
>>>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>> +++
>>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>>> @@ -27,6 +27,7 @@ import
>>>>>>> org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>>>>>>  import org.apache.logging.log4j.spi.LoggerContext;
>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>>>  import org.apache.logging.log4j.spi.Provider;
>>>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>>>  import org.apache.logging.log4j.status.StatusLogger;
>>>>>>>  import org.apache.logging.log4j.util.LoaderUtil;
>>>>>>>  import org.apache.logging.log4j.util.PropertiesUtil;
>>>>>>> @@ -285,6 +286,67 @@ public class LogManager {
>>>>>>>      }
>>>>>>>
>>>>>>>      /**
>>>>>>> +     * Shutdown using the default LoggerContext.
>>>>>>> +     * @since 2.6
>>>>>>> +     */
>>>>>>> +    public static void shutdown() {
>>>>>>> +        shutdown(getContext());
>>>>>>> +    }
>>>>>>> +
>>>>>>> +    /**
>>>>>>> +     * Shutdown the logging system if the logging system supports
>>>>>>> it.
>>>>>>> +     * @param currentContext if true the LoggerContext for the
>>>>>>> caller of this method will be used.
>>>>>>> +     * @since 2.6
>>>>>>> +     */
>>>>>>> +    public static void shutdown(boolean currentContext) {
>>>>>>> +        shutdown(getContext(currentContext));
>>>>>>> +    }
>>>>>>> +
>>>>>>> +    /**
>>>>>>> +     * Shutdown the logging system if the logging system supports
>>>>>>> it.
>>>>>>> +     * @param loader The ClassLoader for the context. If null the
>>>>>>> context will attempt to determine the appropriate
>>>>>>> +     *            ClassLoader.
>>>>>>> +     * @param currentContext if false the LoggerContext appropriate
>>>>>>> for the caller of this method will be used.
>>>>>>> +     * @since 2.6
>>>>>>> +     */
>>>>>>> +    public static void shutdown(final ClassLoader loader, final
>>>>>>> boolean currentContext) {
>>>>>>> +        shutdown(getContext(loader, currentContext));
>>>>>>> +    }
>>>>>>> +
>>>>>>> +    /**
>>>>>>> +     * Shutdown the logging system if the logging system supports
>>>>>>> it.
>>>>>>> +     * @param context the LoggerContext.
>>>>>>> +     * @since 2.6
>>>>>>> +     */
>>>>>>> +    public static void shutdown(LoggerContext context) {
>>>>>>> +        if (context != null && context instanceof ShutdownCapable) {
>>>>>>> +            ((ShutdownCapable) context).shutdown();
>>>>>>> +        }
>>>>>>> +    }
>>>>>>> +
>>>>>>> +    /**
>>>>>>> +     * Shutdown the logging system if the logging system supports
>>>>>>> it.
>>>>>>> +     * @param fqcn The fully qualified class name of the Class that
>>>>>>> this method is a member of.
>>>>>>> +     * @param currentContext if false the LoggerContext appropriate
>>>>>>> for the caller of this method will be used.
>>>>>>> +     * @since 2.6
>>>>>>> +     */
>>>>>>> +    protected static void shutdown(final String fqcn, final boolean
>>>>>>> currentContext) {
>>>>>>> +        shutdown(getContext(fqcn, currentContext));
>>>>>>> +    }
>>>>>>> +
>>>>>>> +    /**
>>>>>>> +     * Shutdown the logging system if the logging system supports
>>>>>>> it.
>>>>>>> +     * @param fqcn The fully qualified class name of the Class that
>>>>>>> this method is a member of.
>>>>>>> +     * @param loader The ClassLoader for the context. If null the
>>>>>>> context will attempt to determine the appropriate
>>>>>>> +     *            ClassLoader.
>>>>>>> +     * @param currentContext if false the LoggerContext appropriate
>>>>>>> for the caller of this method will be used.
>>>>>>> +     * @since 2.6
>>>>>>> +     */
>>>>>>> +    protected static void shutdown(final String fqcn, final
>>>>>>> ClassLoader loader, final boolean currentContext) {
>>>>>>> +        shutdown(getContext(fqcn, loader, currentContext));
>>>>>>> +    }
>>>>>>> +
>>>>>>> +    /**
>>>>>>>       * Returns the current LoggerContextFactory.
>>>>>>>       *
>>>>>>>       * @return The LoggerContextFactory.
>>>>>>>
>>>>>>>
>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>>
>>>>>>> ----------------------------------------------------------------------
>>>>>>> diff --git
>>>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>> new file mode 100644
>>>>>>> index 0000000..a46ef60
>>>>>>> --- /dev/null
>>>>>>> +++
>>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>>> @@ -0,0 +1,17 @@
>>>>>>> +/*
>>>>>>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>>>>>>> + * All rights reserved.
>>>>>>> + */
>>>>>>> +package org.apache.logging.log4j.spi;
>>>>>>> +
>>>>>>> +/**
>>>>>>> + * Interface to be implemented by LoggerContext's that provide a
>>>>>>> shutdown method.
>>>>>>> + * @since 2.6
>>>>>>> + */
>>>>>>> +public interface ShutdownCapable {
>>>>>>> +
>>>>>>> +    /**
>>>>>>> +     * Requests that the logging implementation shut down.
>>>>>>> +     */
>>>>>>> +    void shutdown();
>>>>>>> +}
>>>>>>>
>>>>>>>
>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>>
>>>>>>> ----------------------------------------------------------------------
>>>>>>> diff --git
>>>>>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>> index 48f0eea..596a9f2 100644
>>>>>>> ---
>>>>>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>> +++
>>>>>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>>> @@ -17,6 +17,7 @@
>>>>>>>  package org.apache.logging.log4j;
>>>>>>>
>>>>>>>  import org.apache.logging.log4j.message.ParameterizedMessageFactory;
>>>>>>> +import org.apache.logging.log4j.spi.LoggerContext;
>>>>>>>  import org.junit.Test;
>>>>>>>
>>>>>>>  import static org.junit.Assert.*;
>>>>>>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>>>>>>          assertNotNull("No Logger returned", logger);
>>>>>>>          assertTrue("Incorrect Logger name: " +
>>>>>>> logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>>>>>>      }
>>>>>>> +
>>>>>>> +    @Test
>>>>>>> +    public void testShutdown() {
>>>>>>> +        LoggerContext loggerContext = LogManager.getContext(false);
>>>>>>> +        LogManager.shutdown(loggerContext);
>>>>>>> +    }
>>>>>>>  }
>>>>>>>
>>>>>>>
>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>>
>>>>>>> ----------------------------------------------------------------------
>>>>>>> diff --git
>>>>>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>> index 42efbb5..fcdfc16 100644
>>>>>>> ---
>>>>>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>> +++
>>>>>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>>> @@ -45,6 +45,7 @@ import
>>>>>>> org.apache.logging.log4j.message.MessageFactory;
>>>>>>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>>>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>>>
>>>>>>>  import static
>>>>>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>>>
>>>>>>> @@ -54,7 +55,7 @@ import static
>>>>>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>>>   * filters, etc and will be atomically updated whenever a
>>>>>>> reconfigure occurs.
>>>>>>>   */
>>>>>>>  public class LoggerContext extends AbstractLifeCycle implements
>>>>>>> org.apache.logging.log4j.spi.LoggerContext,
>>>>>>> -        ConfigurationListener {
>>>>>>> +        ShutdownCapable, ConfigurationListener {
>>>>>>>
>>>>>>>      /**
>>>>>>>       * Property name of the property change event fired if the
>>>>>>> configuration is changed.
>>>>>>> @@ -278,6 +279,11 @@ public class LoggerContext extends
>>>>>>> AbstractLifeCycle implements org.apache.loggi
>>>>>>>      }
>>>>>>>
>>>>>>>      @Override
>>>>>>> +    public void shutdown() {
>>>>>>> +        stop();
>>>>>>> +    }
>>>>>>> +
>>>>>>> +    @Override
>>>>>>>      public void stop() {
>>>>>>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...",
>>>>>>> getName(), this);
>>>>>>>          configLock.lock();
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>>> <gg...@apache.org>
>>>>> Java Persistence with Hibernate, Second Edition
>>>>> <http://www.manning.com/bauer3/>
>>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>>> Blog: http://garygregory.wordpress.com
>>>>> Home: http://garygregory.com/
>>>>> Tweet! http://twitter.com/GaryGregory
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>> <gg...@apache.org>
>>>> Java Persistence with Hibernate, Second Edition
>>>> <http://www.manning.com/bauer3/>
>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>> Blog: http://garygregory.wordpress.com
>>>> Home: http://garygregory.com/
>>>> Tweet! http://twitter.com/GaryGregory
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>> Java Persistence with Hibernate, Second Edition
>>> <http://www.manning.com/bauer3/>
>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>> Spring Batch in Action <http://www.manning.com/templier/>
>>> Blog: http://garygregory.wordpress.com
>>> Home: http://garygregory.com/
>>> Tweet! http://twitter.com/GaryGregory
>>>
>>>
>>>
>>
>>
>> --
>> Matt Sicker <bo...@gmail.com>
>>
>>
>>
>
>
> --
> Matt Sicker <bo...@gmail.com>
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.staldal@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.

Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Matt Sicker <bo...@gmail.com>.
I like it!

On 25 January 2016 at 18:23, Ralph Goers <ra...@dslextreme.com> wrote:

> Then the method name would be terminate?  I could live with that.  I also
> like the fact that when something goes wrong with it then it would be
> interminable ;-)
>
> Ralph
>
> On Jan 25, 2016, at 5:18 PM, Matt Sicker <bo...@gmail.com> wrote:
>
> How about Terminable? It's even a real word to boot.
>
> On 25 January 2016 at 18:15, Ralph Goers <ra...@dslextreme.com>
> wrote:
>
>> Yes, well - Serializable actually sounds like it should be a real word.
>> Shutdownable doesn’t - in fact, my mail editor just split it into two words
>> to “help” me. I take a different view. A class that declares it implements
>> an interface isn’t “capable” of anything - it just implements the
>> interface. The interface name is what tells you that the implementing class
>> is able to do something, which is why you have Comparable instead of just
>> Compare, Cloneable instead of just Clone,  or Closeable instead of just
>> Close. Would you want Stop instead of Stoppable?  I view “able” as just a
>> shorthand way of saying “Capable”, but unfortunately that just doesn’t
>> sound right with Shutdown (at least to me).
>>
>> Here are some “able” alternatives - presumably each would have a
>> corresponding method name instead of shutdown:
>> Terminateable.
>> Completeable.
>> Concludeable.
>> Haltable.
>> Dismissable.
>> Expireable.
>>
>> I suppose we could also use Stoppable but that seems odd since stop is
>> part of Lifecycle.
>>
>> Got a preference?
>>
>> Ralph
>>
>>
>>
>> On Jan 25, 2016, at 4:35 PM, Gary Gregory <ga...@gmail.com> wrote:
>>
>> I see some interfaces with "*Capable*" in the name here and there in the
>> FOSS world (but not in the JRE) so I am a little more comfortable with it.
>>
>> I still see plain old "Shutdown" as simpler.
>>
>> I think I've boiled down my feel for this name to the fact that the
>> Capable postfix is redundant since a class implementing any interface is
>> "capable" of that functionality. IOW we have Serializable vs.
>> SerializationCabable, which means the same thing.
>>
>> Gary
>>
>> On Mon, Jan 25, 2016 at 7:27 AM, Ralph Goers <ra...@dslextreme.com>
>> wrote:
>>
>>> What does it feel weird to you?  To be honest, I originally named the
>>> interface ‘Shutdown” and then changed it since it really is about
>>> implementing a behavior and “Shutdown” alone doesn’t really describe that.
>>>
>>> Ralph
>>>
>>> On Jan 24, 2016, at 11:09 PM, Gary Gregory <ga...@gmail.com>
>>> wrote:
>>>
>>> On Sun, Jan 24, 2016 at 10:07 PM, Gary Gregory <ga...@gmail.com>
>>> wrote:
>>>
>>>> On Sun, Jan 24, 2016 at 1:54 PM, Ralph Goers <
>>>> ralph.goers@dslextreme.com> wrote:
>>>>
>>>>> Yes, Shutdownable is too weird.
>>>>>
>>>>
>>>> How about calling it simply "Shutdown" then? FooCapable feels weird to
>>>> me.
>>>>
>>>> Can anyone think of other (one-method or not) optional feature-like
>>>> interfaces in the JRE or other code base?
>>>>
>>>
>>> hm... ShutdownService?
>>>
>>> Gary
>>>
>>>
>>>>
>>>> Gary
>>>>
>>>> Closeable would imply there is a close method, not a shutdown method.
>>>>> I have my doubts about the try-with-resources use case here.  Virtually all
>>>>> usages are probably going to be to disable automatic shutdown and then the
>>>>> user placing the shutdown call somewhere they can control, which probably
>>>>> will have nothing to do with initialization of logging.
>>>>>
>>>>> Ralph
>>>>>
>>>>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <ga...@gmail.com>
>>>>> wrote:
>>>>>
>>>>> Resending, got a error from my phone...
>>>>> ---------- Forwarded message ----------
>>>>> From: "Gary Gregory" <ga...@gmail.com>
>>>>> Date: Jan 24, 2016 1:41 PM
>>>>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown
>>>>> methods to LogManager
>>>>> To: <de...@logging.apache.org>
>>>>> Cc:
>>>>>
>>>>> Hi all,
>>>>>
>>>>> Any reason not use the usual -able postfix instead of ShutdownCapable:
>>>>> Shutdownable sounds too weird? What about reusing plain old Closeable? That
>>>>> means you could use the context in a try-with-resources block, a bonus.
>>>>>
>>>>> Gary
>>>>> On Jan 24, 2016 10:18 AM, <rg...@apache.org> wrote:
>>>>>
>>>>>> Repository: logging-log4j2
>>>>>> Updated Branches:
>>>>>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>>>>>>
>>>>>>
>>>>>> LOG4J2-124 - Add shutdown methods to LogManager
>>>>>>
>>>>>>
>>>>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>>>>> Commit:
>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7
>>>>>> Tree:
>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7
>>>>>> Diff:
>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7
>>>>>>
>>>>>> Branch: refs/heads/master
>>>>>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>>>>>> Parents: 7d3aac4
>>>>>> Author: Ralph Goers <rg...@nextiva.com>
>>>>>> Authored: Sun Jan 24 11:18:41 2016 -0700
>>>>>> Committer: Ralph Goers <rg...@nextiva.com>
>>>>>> Committed: Sun Jan 24 11:18:41 2016 -0700
>>>>>>
>>>>>> ----------------------------------------------------------------------
>>>>>>  .../org/apache/logging/log4j/LogManager.java    | 62
>>>>>> ++++++++++++++++++++
>>>>>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>>>>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>>>>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>>>>>  4 files changed, 93 insertions(+), 1 deletion(-)
>>>>>> ----------------------------------------------------------------------
>>>>>>
>>>>>>
>>>>>>
>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>> ----------------------------------------------------------------------
>>>>>> diff --git
>>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>> index f10e5a8..64c6ee5 100644
>>>>>> --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>>> @@ -27,6 +27,7 @@ import
>>>>>> org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>>>>>  import org.apache.logging.log4j.spi.LoggerContext;
>>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>>  import org.apache.logging.log4j.spi.Provider;
>>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>>  import org.apache.logging.log4j.status.StatusLogger;
>>>>>>  import org.apache.logging.log4j.util.LoaderUtil;
>>>>>>  import org.apache.logging.log4j.util.PropertiesUtil;
>>>>>> @@ -285,6 +286,67 @@ public class LogManager {
>>>>>>      }
>>>>>>
>>>>>>      /**
>>>>>> +     * Shutdown using the default LoggerContext.
>>>>>> +     * @since 2.6
>>>>>> +     */
>>>>>> +    public static void shutdown() {
>>>>>> +        shutdown(getContext());
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>>> +     * @param currentContext if true the LoggerContext for the
>>>>>> caller of this method will be used.
>>>>>> +     * @since 2.6
>>>>>> +     */
>>>>>> +    public static void shutdown(boolean currentContext) {
>>>>>> +        shutdown(getContext(currentContext));
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>>> +     * @param loader The ClassLoader for the context. If null the
>>>>>> context will attempt to determine the appropriate
>>>>>> +     *            ClassLoader.
>>>>>> +     * @param currentContext if false the LoggerContext appropriate
>>>>>> for the caller of this method will be used.
>>>>>> +     * @since 2.6
>>>>>> +     */
>>>>>> +    public static void shutdown(final ClassLoader loader, final
>>>>>> boolean currentContext) {
>>>>>> +        shutdown(getContext(loader, currentContext));
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>>> +     * @param context the LoggerContext.
>>>>>> +     * @since 2.6
>>>>>> +     */
>>>>>> +    public static void shutdown(LoggerContext context) {
>>>>>> +        if (context != null && context instanceof ShutdownCapable) {
>>>>>> +            ((ShutdownCapable) context).shutdown();
>>>>>> +        }
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>>> +     * @param fqcn The fully qualified class name of the Class that
>>>>>> this method is a member of.
>>>>>> +     * @param currentContext if false the LoggerContext appropriate
>>>>>> for the caller of this method will be used.
>>>>>> +     * @since 2.6
>>>>>> +     */
>>>>>> +    protected static void shutdown(final String fqcn, final boolean
>>>>>> currentContext) {
>>>>>> +        shutdown(getContext(fqcn, currentContext));
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>>> +     * @param fqcn The fully qualified class name of the Class that
>>>>>> this method is a member of.
>>>>>> +     * @param loader The ClassLoader for the context. If null the
>>>>>> context will attempt to determine the appropriate
>>>>>> +     *            ClassLoader.
>>>>>> +     * @param currentContext if false the LoggerContext appropriate
>>>>>> for the caller of this method will be used.
>>>>>> +     * @since 2.6
>>>>>> +     */
>>>>>> +    protected static void shutdown(final String fqcn, final
>>>>>> ClassLoader loader, final boolean currentContext) {
>>>>>> +        shutdown(getContext(fqcn, loader, currentContext));
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>>       * Returns the current LoggerContextFactory.
>>>>>>       *
>>>>>>       * @return The LoggerContextFactory.
>>>>>>
>>>>>>
>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>> ----------------------------------------------------------------------
>>>>>> diff --git
>>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>> new file mode 100644
>>>>>> index 0000000..a46ef60
>>>>>> --- /dev/null
>>>>>> +++
>>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>>> @@ -0,0 +1,17 @@
>>>>>> +/*
>>>>>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>>>>>> + * All rights reserved.
>>>>>> + */
>>>>>> +package org.apache.logging.log4j.spi;
>>>>>> +
>>>>>> +/**
>>>>>> + * Interface to be implemented by LoggerContext's that provide a
>>>>>> shutdown method.
>>>>>> + * @since 2.6
>>>>>> + */
>>>>>> +public interface ShutdownCapable {
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Requests that the logging implementation shut down.
>>>>>> +     */
>>>>>> +    void shutdown();
>>>>>> +}
>>>>>>
>>>>>>
>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>> ----------------------------------------------------------------------
>>>>>> diff --git
>>>>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>> index 48f0eea..596a9f2 100644
>>>>>> ---
>>>>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>> +++
>>>>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>>> @@ -17,6 +17,7 @@
>>>>>>  package org.apache.logging.log4j;
>>>>>>
>>>>>>  import org.apache.logging.log4j.message.ParameterizedMessageFactory;
>>>>>> +import org.apache.logging.log4j.spi.LoggerContext;
>>>>>>  import org.junit.Test;
>>>>>>
>>>>>>  import static org.junit.Assert.*;
>>>>>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>>>>>          assertNotNull("No Logger returned", logger);
>>>>>>          assertTrue("Incorrect Logger name: " +
>>>>>> logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>>>>>      }
>>>>>> +
>>>>>> +    @Test
>>>>>> +    public void testShutdown() {
>>>>>> +        LoggerContext loggerContext = LogManager.getContext(false);
>>>>>> +        LogManager.shutdown(loggerContext);
>>>>>> +    }
>>>>>>  }
>>>>>>
>>>>>>
>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>> ----------------------------------------------------------------------
>>>>>> diff --git
>>>>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>> index 42efbb5..fcdfc16 100644
>>>>>> ---
>>>>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>> +++
>>>>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>>> @@ -45,6 +45,7 @@ import
>>>>>> org.apache.logging.log4j.message.MessageFactory;
>>>>>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>>
>>>>>>  import static
>>>>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>>
>>>>>> @@ -54,7 +55,7 @@ import static
>>>>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>>   * filters, etc and will be atomically updated whenever a
>>>>>> reconfigure occurs.
>>>>>>   */
>>>>>>  public class LoggerContext extends AbstractLifeCycle implements
>>>>>> org.apache.logging.log4j.spi.LoggerContext,
>>>>>> -        ConfigurationListener {
>>>>>> +        ShutdownCapable, ConfigurationListener {
>>>>>>
>>>>>>      /**
>>>>>>       * Property name of the property change event fired if the
>>>>>> configuration is changed.
>>>>>> @@ -278,6 +279,11 @@ public class LoggerContext extends
>>>>>> AbstractLifeCycle implements org.apache.loggi
>>>>>>      }
>>>>>>
>>>>>>      @Override
>>>>>> +    public void shutdown() {
>>>>>> +        stop();
>>>>>> +    }
>>>>>> +
>>>>>> +    @Override
>>>>>>      public void stop() {
>>>>>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...",
>>>>>> getName(), this);
>>>>>>          configLock.lock();
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>> <gg...@apache.org>
>>>> Java Persistence with Hibernate, Second Edition
>>>> <http://www.manning.com/bauer3/>
>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>> Blog: http://garygregory.wordpress.com
>>>> Home: http://garygregory.com/
>>>> Tweet! http://twitter.com/GaryGregory
>>>>
>>>
>>>
>>>
>>> --
>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>> <gg...@apache.org>
>>> Java Persistence with Hibernate, Second Edition
>>> <http://www.manning.com/bauer3/>
>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>> Spring Batch in Action <http://www.manning.com/templier/>
>>> Blog: http://garygregory.wordpress.com
>>> Home: http://garygregory.com/
>>> Tweet! http://twitter.com/GaryGregory
>>>
>>>
>>>
>>
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> Java Persistence with Hibernate, Second Edition
>> <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
>>
>>
>>
>
>
> --
> Matt Sicker <bo...@gmail.com>
>
>
>


-- 
Matt Sicker <bo...@gmail.com>

Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Ralph Goers <ra...@dslextreme.com>.
Then the method name would be terminate?  I could live with that.  I also like the fact that when something goes wrong with it then it would be interminable ;-)

Ralph

> On Jan 25, 2016, at 5:18 PM, Matt Sicker <bo...@gmail.com> wrote:
> 
> How about Terminable? It's even a real word to boot.
> 
> On 25 January 2016 at 18:15, Ralph Goers <ralph.goers@dslextreme.com <ma...@dslextreme.com>> wrote:
> Yes, well - Serializable actually sounds like it should be a real word. Shutdownable doesn’t - in fact, my mail editor just split it into two words to “help” me. I take a different view. A class that declares it implements an interface isn’t “capable” of anything - it just implements the interface. The interface name is what tells you that the implementing class is able to do something, which is why you have Comparable instead of just Compare, Cloneable instead of just Clone,  or Closeable instead of just Close. Would you want Stop instead of Stoppable?  I view “able” as just a shorthand way of saying “Capable”, but unfortunately that just doesn’t sound right with Shutdown (at least to me).
> 
> Here are some “able” alternatives - presumably each would have a corresponding method name instead of shutdown:
> Terminateable.
> Completeable.
> Concludeable.
> Haltable.
> Dismissable.
> Expireable.
> 
> I suppose we could also use Stoppable but that seems odd since stop is part of Lifecycle.
> 
> Got a preference?
> 
> Ralph
> 
> 
> 
>> On Jan 25, 2016, at 4:35 PM, Gary Gregory <garydgregory@gmail.com <ma...@gmail.com>> wrote:
>> 
>> I see some interfaces with "*Capable*" in the name here and there in the FOSS world (but not in the JRE) so I am a little more comfortable with it. 
>> 
>> I still see plain old "Shutdown" as simpler. 
>> 
>> I think I've boiled down my feel for this name to the fact that the Capable postfix is redundant since a class implementing any interface is "capable" of that functionality. IOW we have Serializable vs. SerializationCabable, which means the same thing.
>> 
>> Gary
>> 
>> On Mon, Jan 25, 2016 at 7:27 AM, Ralph Goers <ralph.goers@dslextreme.com <ma...@dslextreme.com>> wrote:
>> What does it feel weird to you?  To be honest, I originally named the interface ‘Shutdown” and then changed it since it really is about implementing a behavior and “Shutdown” alone doesn’t really describe that.
>> 
>> Ralph
>> 
>>> On Jan 24, 2016, at 11:09 PM, Gary Gregory <garydgregory@gmail.com <ma...@gmail.com>> wrote:
>>> 
>>> On Sun, Jan 24, 2016 at 10:07 PM, Gary Gregory <garydgregory@gmail.com <ma...@gmail.com>> wrote:
>>> On Sun, Jan 24, 2016 at 1:54 PM, Ralph Goers <ralph.goers@dslextreme.com <ma...@dslextreme.com>> wrote:
>>> Yes, Shutdownable is too weird. 
>>> 
>>> How about calling it simply "Shutdown" then? FooCapable feels weird to me.
>>> 
>>> Can anyone think of other (one-method or not) optional feature-like interfaces in the JRE or other code base?
>>> 
>>> hm... ShutdownService?
>>> 
>>> Gary
>>>  
>>> 
>>> Gary
>>> 
>>> Closeable would imply there is a close method, not a shutdown method.  I have my doubts about the try-with-resources use case here.  Virtually all usages are probably going to be to disable automatic shutdown and then the user placing the shutdown call somewhere they can control, which probably will have nothing to do with initialization of logging. 
>>> 
>>> Ralph
>>> 
>>>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <garydgregory@gmail.com <ma...@gmail.com>> wrote:
>>>> 
>>>> Resending, got a error from my phone...
>>>> 
>>>> ---------- Forwarded message ----------
>>>> From: "Gary Gregory" <garydgregory@gmail.com <ma...@gmail.com>>
>>>> Date: Jan 24, 2016 1:41 PM
>>>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager
>>>> To: <dev@logging.apache.org <ma...@logging.apache.org>>
>>>> Cc: 
>>>> 
>>>> Hi all,
>>>> 
>>>> Any reason not use the usual -able postfix instead of ShutdownCapable: Shutdownable sounds too weird? What about reusing plain old Closeable? That means you could use the context in a try-with-resources block, a bonus.
>>>> 
>>>> Gary 
>>>> 
>>>> On Jan 24, 2016 10:18 AM, <rgoers@apache.org <ma...@apache.org>> wrote:
>>>> Repository: logging-log4j2
>>>> Updated Branches:
>>>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>>>> 
>>>> 
>>>> LOG4J2-124 - Add shutdown methods to LogManager
>>>> 
>>>> 
>>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo <http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo>
>>>> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7>
>>>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7>
>>>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7>
>>>> 
>>>> Branch: refs/heads/master
>>>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>>>> Parents: 7d3aac4
>>>> Author: Ralph Goers <rgoers@nextiva.com <ma...@nextiva.com>>
>>>> Authored: Sun Jan 24 11:18:41 2016 -0700
>>>> Committer: Ralph Goers <rgoers@nextiva.com <ma...@nextiva.com>>
>>>> Committed: Sun Jan 24 11:18:41 2016 -0700
>>>> 
>>>> ----------------------------------------------------------------------
>>>>  .../org/apache/logging/log4j/LogManager.java    | 62 ++++++++++++++++++++
>>>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>>>  4 files changed, 93 insertions(+), 1 deletion(-)
>>>> ----------------------------------------------------------------------
>>>> 
>>>> 
>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java>
>>>> ----------------------------------------------------------------------
>>>> diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>> index f10e5a8..64c6ee5 100644
>>>> --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>> @@ -27,6 +27,7 @@ import org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>>>  import org.apache.logging.log4j.spi.LoggerContext;
>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>  import org.apache.logging.log4j.spi.Provider;
>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>  import org.apache.logging.log4j.status.StatusLogger;
>>>>  import org.apache.logging.log4j.util.LoaderUtil;
>>>>  import org.apache.logging.log4j.util.PropertiesUtil;
>>>> @@ -285,6 +286,67 @@ public class LogManager {
>>>>      }
>>>> 
>>>>      /**
>>>> +     * Shutdown using the default LoggerContext.
>>>> +     * @since 2.6
>>>> +     */
>>>> +    public static void shutdown() {
>>>> +        shutdown(getContext());
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Shutdown the logging system if the logging system supports it.
>>>> +     * @param currentContext if true the LoggerContext for the caller of this method will be used.
>>>> +     * @since 2.6
>>>> +     */
>>>> +    public static void shutdown(boolean currentContext) {
>>>> +        shutdown(getContext(currentContext));
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Shutdown the logging system if the logging system supports it.
>>>> +     * @param loader The ClassLoader for the context. If null the context will attempt to determine the appropriate
>>>> +     *            ClassLoader.
>>>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>>>> +     * @since 2.6
>>>> +     */
>>>> +    public static void shutdown(final ClassLoader loader, final boolean currentContext) {
>>>> +        shutdown(getContext(loader, currentContext));
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Shutdown the logging system if the logging system supports it.
>>>> +     * @param context the LoggerContext.
>>>> +     * @since 2.6
>>>> +     */
>>>> +    public static void shutdown(LoggerContext context) {
>>>> +        if (context != null && context instanceof ShutdownCapable) {
>>>> +            ((ShutdownCapable) context).shutdown();
>>>> +        }
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Shutdown the logging system if the logging system supports it.
>>>> +     * @param fqcn The fully qualified class name of the Class that this method is a member of.
>>>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>>>> +     * @since 2.6
>>>> +     */
>>>> +    protected static void shutdown(final String fqcn, final boolean currentContext) {
>>>> +        shutdown(getContext(fqcn, currentContext));
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Shutdown the logging system if the logging system supports it.
>>>> +     * @param fqcn The fully qualified class name of the Class that this method is a member of.
>>>> +     * @param loader The ClassLoader for the context. If null the context will attempt to determine the appropriate
>>>> +     *            ClassLoader.
>>>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>>>> +     * @since 2.6
>>>> +     */
>>>> +    protected static void shutdown(final String fqcn, final ClassLoader loader, final boolean currentContext) {
>>>> +        shutdown(getContext(fqcn, loader, currentContext));
>>>> +    }
>>>> +
>>>> +    /**
>>>>       * Returns the current LoggerContextFactory.
>>>>       *
>>>>       * @return The LoggerContextFactory.
>>>> 
>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java>
>>>> ----------------------------------------------------------------------
>>>> diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>> new file mode 100644
>>>> index 0000000..a46ef60
>>>> --- /dev/null
>>>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>> @@ -0,0 +1,17 @@
>>>> +/*
>>>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>>>> + * All rights reserved.
>>>> + */
>>>> +package org.apache.logging.log4j.spi;
>>>> +
>>>> +/**
>>>> + * Interface to be implemented by LoggerContext's that provide a shutdown method.
>>>> + * @since 2.6
>>>> + */
>>>> +public interface ShutdownCapable {
>>>> +
>>>> +    /**
>>>> +     * Requests that the logging implementation shut down.
>>>> +     */
>>>> +    void shutdown();
>>>> +}
>>>> 
>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java>
>>>> ----------------------------------------------------------------------
>>>> diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>> index 48f0eea..596a9f2 100644
>>>> --- a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>> +++ b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>> @@ -17,6 +17,7 @@
>>>>  package org.apache.logging.log4j;
>>>> 
>>>>  import org.apache.logging.log4j.message.ParameterizedMessageFactory;
>>>> +import org.apache.logging.log4j.spi.LoggerContext;
>>>>  import org.junit.Test;
>>>> 
>>>>  import static org.junit.Assert.*;
>>>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>>>          assertNotNull("No Logger returned", logger);
>>>>          assertTrue("Incorrect Logger name: " + logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>>>      }
>>>> +
>>>> +    @Test
>>>> +    public void testShutdown() {
>>>> +        LoggerContext loggerContext = LogManager.getContext(false);
>>>> +        LogManager.shutdown(loggerContext);
>>>> +    }
>>>>  }
>>>> 
>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java>
>>>> ----------------------------------------------------------------------
>>>> diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>> index 42efbb5..fcdfc16 100644
>>>> --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>> +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>> @@ -45,6 +45,7 @@ import org.apache.logging.log4j.message.MessageFactory;
>>>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>> 
>>>>  import static org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>> 
>>>> @@ -54,7 +55,7 @@ import static org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>   * filters, etc and will be atomically updated whenever a reconfigure occurs.
>>>>   */
>>>>  public class LoggerContext extends AbstractLifeCycle implements org.apache.logging.log4j.spi.LoggerContext,
>>>> -        ConfigurationListener {
>>>> +        ShutdownCapable, ConfigurationListener {
>>>> 
>>>>      /**
>>>>       * Property name of the property change event fired if the configuration is changed.
>>>> @@ -278,6 +279,11 @@ public class LoggerContext extends AbstractLifeCycle implements org.apache.loggi
>>>>      }
>>>> 
>>>>      @Override
>>>> +    public void shutdown() {
>>>> +        stop();
>>>> +    }
>>>> +
>>>> +    @Override
>>>>      public void stop() {
>>>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...", getName(), this);
>>>>          configLock.lock();
>>>> 
>>> 
>>> 
>>> 
>>> 
>>> -- 
>>> E-Mail: garydgregory@gmail.com <ma...@gmail.com> | ggregory@apache.org  <ma...@apache.org>
>>> Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/>
>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>> Spring Batch in Action <http://www.manning.com/templier/>
>>> Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> 
>>> Home: http://garygregory.com/ <http://garygregory.com/>
>>> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>
>>> 
>>> 
>>> -- 
>>> E-Mail: garydgregory@gmail.com <ma...@gmail.com> | ggregory@apache.org  <ma...@apache.org>
>>> Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/>
>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>> Spring Batch in Action <http://www.manning.com/templier/>
>>> Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> 
>>> Home: http://garygregory.com/ <http://garygregory.com/>
>>> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>
>> 
>> 
>> 
>> -- 
>> E-Mail: garydgregory@gmail.com <ma...@gmail.com> | ggregory@apache.org  <ma...@apache.org>
>> Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> 
>> Home: http://garygregory.com/ <http://garygregory.com/>
>> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>
> 
> 
> 
> -- 
> Matt Sicker <boards@gmail.com <ma...@gmail.com>>


Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Matt Sicker <bo...@gmail.com>.
How about Terminable? It's even a real word to boot.

On 25 January 2016 at 18:15, Ralph Goers <ra...@dslextreme.com> wrote:

> Yes, well - Serializable actually sounds like it should be a real word.
> Shutdownable doesn’t - in fact, my mail editor just split it into two words
> to “help” me. I take a different view. A class that declares it implements
> an interface isn’t “capable” of anything - it just implements the
> interface. The interface name is what tells you that the implementing class
> is able to do something, which is why you have Comparable instead of just
> Compare, Cloneable instead of just Clone,  or Closeable instead of just
> Close. Would you want Stop instead of Stoppable?  I view “able” as just a
> shorthand way of saying “Capable”, but unfortunately that just doesn’t
> sound right with Shutdown (at least to me).
>
> Here are some “able” alternatives - presumably each would have a
> corresponding method name instead of shutdown:
> Terminateable.
> Completeable.
> Concludeable.
> Haltable.
> Dismissable.
> Expireable.
>
> I suppose we could also use Stoppable but that seems odd since stop is
> part of Lifecycle.
>
> Got a preference?
>
> Ralph
>
>
>
> On Jan 25, 2016, at 4:35 PM, Gary Gregory <ga...@gmail.com> wrote:
>
> I see some interfaces with "*Capable*" in the name here and there in the
> FOSS world (but not in the JRE) so I am a little more comfortable with it.
>
> I still see plain old "Shutdown" as simpler.
>
> I think I've boiled down my feel for this name to the fact that the
> Capable postfix is redundant since a class implementing any interface is
> "capable" of that functionality. IOW we have Serializable vs.
> SerializationCabable, which means the same thing.
>
> Gary
>
> On Mon, Jan 25, 2016 at 7:27 AM, Ralph Goers <ra...@dslextreme.com>
> wrote:
>
>> What does it feel weird to you?  To be honest, I originally named the
>> interface ‘Shutdown” and then changed it since it really is about
>> implementing a behavior and “Shutdown” alone doesn’t really describe that.
>>
>> Ralph
>>
>> On Jan 24, 2016, at 11:09 PM, Gary Gregory <ga...@gmail.com>
>> wrote:
>>
>> On Sun, Jan 24, 2016 at 10:07 PM, Gary Gregory <ga...@gmail.com>
>> wrote:
>>
>>> On Sun, Jan 24, 2016 at 1:54 PM, Ralph Goers <ralph.goers@dslextreme.com
>>> > wrote:
>>>
>>>> Yes, Shutdownable is too weird.
>>>>
>>>
>>> How about calling it simply "Shutdown" then? FooCapable feels weird to
>>> me.
>>>
>>> Can anyone think of other (one-method or not) optional feature-like
>>> interfaces in the JRE or other code base?
>>>
>>
>> hm... ShutdownService?
>>
>> Gary
>>
>>
>>>
>>> Gary
>>>
>>> Closeable would imply there is a close method, not a shutdown method.  I
>>>> have my doubts about the try-with-resources use case here.  Virtually all
>>>> usages are probably going to be to disable automatic shutdown and then the
>>>> user placing the shutdown call somewhere they can control, which probably
>>>> will have nothing to do with initialization of logging.
>>>>
>>>> Ralph
>>>>
>>>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <ga...@gmail.com>
>>>> wrote:
>>>>
>>>> Resending, got a error from my phone...
>>>> ---------- Forwarded message ----------
>>>> From: "Gary Gregory" <ga...@gmail.com>
>>>> Date: Jan 24, 2016 1:41 PM
>>>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown
>>>> methods to LogManager
>>>> To: <de...@logging.apache.org>
>>>> Cc:
>>>>
>>>> Hi all,
>>>>
>>>> Any reason not use the usual -able postfix instead of ShutdownCapable:
>>>> Shutdownable sounds too weird? What about reusing plain old Closeable? That
>>>> means you could use the context in a try-with-resources block, a bonus.
>>>>
>>>> Gary
>>>> On Jan 24, 2016 10:18 AM, <rg...@apache.org> wrote:
>>>>
>>>>> Repository: logging-log4j2
>>>>> Updated Branches:
>>>>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>>>>>
>>>>>
>>>>> LOG4J2-124 - Add shutdown methods to LogManager
>>>>>
>>>>>
>>>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>>>> Commit:
>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7
>>>>> Tree:
>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7
>>>>> Diff:
>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7
>>>>>
>>>>> Branch: refs/heads/master
>>>>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>>>>> Parents: 7d3aac4
>>>>> Author: Ralph Goers <rg...@nextiva.com>
>>>>> Authored: Sun Jan 24 11:18:41 2016 -0700
>>>>> Committer: Ralph Goers <rg...@nextiva.com>
>>>>> Committed: Sun Jan 24 11:18:41 2016 -0700
>>>>>
>>>>> ----------------------------------------------------------------------
>>>>>  .../org/apache/logging/log4j/LogManager.java    | 62
>>>>> ++++++++++++++++++++
>>>>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>>>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>>>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>>>>  4 files changed, 93 insertions(+), 1 deletion(-)
>>>>> ----------------------------------------------------------------------
>>>>>
>>>>>
>>>>>
>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>> ----------------------------------------------------------------------
>>>>> diff --git
>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>> index f10e5a8..64c6ee5 100644
>>>>> --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>>> @@ -27,6 +27,7 @@ import
>>>>> org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>>>>  import org.apache.logging.log4j.spi.LoggerContext;
>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>  import org.apache.logging.log4j.spi.Provider;
>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>  import org.apache.logging.log4j.status.StatusLogger;
>>>>>  import org.apache.logging.log4j.util.LoaderUtil;
>>>>>  import org.apache.logging.log4j.util.PropertiesUtil;
>>>>> @@ -285,6 +286,67 @@ public class LogManager {
>>>>>      }
>>>>>
>>>>>      /**
>>>>> +     * Shutdown using the default LoggerContext.
>>>>> +     * @since 2.6
>>>>> +     */
>>>>> +    public static void shutdown() {
>>>>> +        shutdown(getContext());
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>> +     * @param currentContext if true the LoggerContext for the caller
>>>>> of this method will be used.
>>>>> +     * @since 2.6
>>>>> +     */
>>>>> +    public static void shutdown(boolean currentContext) {
>>>>> +        shutdown(getContext(currentContext));
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>> +     * @param loader The ClassLoader for the context. If null the
>>>>> context will attempt to determine the appropriate
>>>>> +     *            ClassLoader.
>>>>> +     * @param currentContext if false the LoggerContext appropriate
>>>>> for the caller of this method will be used.
>>>>> +     * @since 2.6
>>>>> +     */
>>>>> +    public static void shutdown(final ClassLoader loader, final
>>>>> boolean currentContext) {
>>>>> +        shutdown(getContext(loader, currentContext));
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>> +     * @param context the LoggerContext.
>>>>> +     * @since 2.6
>>>>> +     */
>>>>> +    public static void shutdown(LoggerContext context) {
>>>>> +        if (context != null && context instanceof ShutdownCapable) {
>>>>> +            ((ShutdownCapable) context).shutdown();
>>>>> +        }
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>> +     * @param fqcn The fully qualified class name of the Class that
>>>>> this method is a member of.
>>>>> +     * @param currentContext if false the LoggerContext appropriate
>>>>> for the caller of this method will be used.
>>>>> +     * @since 2.6
>>>>> +     */
>>>>> +    protected static void shutdown(final String fqcn, final boolean
>>>>> currentContext) {
>>>>> +        shutdown(getContext(fqcn, currentContext));
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Shutdown the logging system if the logging system supports it.
>>>>> +     * @param fqcn The fully qualified class name of the Class that
>>>>> this method is a member of.
>>>>> +     * @param loader The ClassLoader for the context. If null the
>>>>> context will attempt to determine the appropriate
>>>>> +     *            ClassLoader.
>>>>> +     * @param currentContext if false the LoggerContext appropriate
>>>>> for the caller of this method will be used.
>>>>> +     * @since 2.6
>>>>> +     */
>>>>> +    protected static void shutdown(final String fqcn, final
>>>>> ClassLoader loader, final boolean currentContext) {
>>>>> +        shutdown(getContext(fqcn, loader, currentContext));
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>>       * Returns the current LoggerContextFactory.
>>>>>       *
>>>>>       * @return The LoggerContextFactory.
>>>>>
>>>>>
>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>> ----------------------------------------------------------------------
>>>>> diff --git
>>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>> new file mode 100644
>>>>> index 0000000..a46ef60
>>>>> --- /dev/null
>>>>> +++
>>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>>> @@ -0,0 +1,17 @@
>>>>> +/*
>>>>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>>>>> + * All rights reserved.
>>>>> + */
>>>>> +package org.apache.logging.log4j.spi;
>>>>> +
>>>>> +/**
>>>>> + * Interface to be implemented by LoggerContext's that provide a
>>>>> shutdown method.
>>>>> + * @since 2.6
>>>>> + */
>>>>> +public interface ShutdownCapable {
>>>>> +
>>>>> +    /**
>>>>> +     * Requests that the logging implementation shut down.
>>>>> +     */
>>>>> +    void shutdown();
>>>>> +}
>>>>>
>>>>>
>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>> ----------------------------------------------------------------------
>>>>> diff --git
>>>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>> index 48f0eea..596a9f2 100644
>>>>> ---
>>>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>> +++
>>>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>>> @@ -17,6 +17,7 @@
>>>>>  package org.apache.logging.log4j;
>>>>>
>>>>>  import org.apache.logging.log4j.message.ParameterizedMessageFactory;
>>>>> +import org.apache.logging.log4j.spi.LoggerContext;
>>>>>  import org.junit.Test;
>>>>>
>>>>>  import static org.junit.Assert.*;
>>>>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>>>>          assertNotNull("No Logger returned", logger);
>>>>>          assertTrue("Incorrect Logger name: " +
>>>>> logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>>>>      }
>>>>> +
>>>>> +    @Test
>>>>> +    public void testShutdown() {
>>>>> +        LoggerContext loggerContext = LogManager.getContext(false);
>>>>> +        LogManager.shutdown(loggerContext);
>>>>> +    }
>>>>>  }
>>>>>
>>>>>
>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>> ----------------------------------------------------------------------
>>>>> diff --git
>>>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>> index 42efbb5..fcdfc16 100644
>>>>> ---
>>>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>> +++
>>>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>>> @@ -45,6 +45,7 @@ import
>>>>> org.apache.logging.log4j.message.MessageFactory;
>>>>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>>
>>>>>  import static
>>>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>
>>>>> @@ -54,7 +55,7 @@ import static
>>>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>>   * filters, etc and will be atomically updated whenever a
>>>>> reconfigure occurs.
>>>>>   */
>>>>>  public class LoggerContext extends AbstractLifeCycle implements
>>>>> org.apache.logging.log4j.spi.LoggerContext,
>>>>> -        ConfigurationListener {
>>>>> +        ShutdownCapable, ConfigurationListener {
>>>>>
>>>>>      /**
>>>>>       * Property name of the property change event fired if the
>>>>> configuration is changed.
>>>>> @@ -278,6 +279,11 @@ public class LoggerContext extends
>>>>> AbstractLifeCycle implements org.apache.loggi
>>>>>      }
>>>>>
>>>>>      @Override
>>>>> +    public void shutdown() {
>>>>> +        stop();
>>>>> +    }
>>>>> +
>>>>> +    @Override
>>>>>      public void stop() {
>>>>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...",
>>>>> getName(), this);
>>>>>          configLock.lock();
>>>>>
>>>>>
>>>>
>>>
>>>
>>> --
>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>> <gg...@apache.org>
>>> Java Persistence with Hibernate, Second Edition
>>> <http://www.manning.com/bauer3/>
>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>> Spring Batch in Action <http://www.manning.com/templier/>
>>> Blog: http://garygregory.wordpress.com
>>> Home: http://garygregory.com/
>>> Tweet! http://twitter.com/GaryGregory
>>>
>>
>>
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> <gg...@apache.org>
>> Java Persistence with Hibernate, Second Edition
>> <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
>>
>>
>>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>
>
>


-- 
Matt Sicker <bo...@gmail.com>

Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Ralph Goers <ra...@dslextreme.com>.
Yes, well - Serializable actually sounds like it should be a real word. Shutdownable doesn’t - in fact, my mail editor just split it into two words to “help” me. I take a different view. A class that declares it implements an interface isn’t “capable” of anything - it just implements the interface. The interface name is what tells you that the implementing class is able to do something, which is why you have Comparable instead of just Compare, Cloneable instead of just Clone,  or Closeable instead of just Close. Would you want Stop instead of Stoppable?  I view “able” as just a shorthand way of saying “Capable”, but unfortunately that just doesn’t sound right with Shutdown (at least to me).

Here are some “able” alternatives - presumably each would have a corresponding method name instead of shutdown:
Terminateable.
Completeable.
Concludeable.
Haltable.
Dismissable.
Expireable.

I suppose we could also use Stoppable but that seems odd since stop is part of Lifecycle.

Got a preference?

Ralph



> On Jan 25, 2016, at 4:35 PM, Gary Gregory <ga...@gmail.com> wrote:
> 
> I see some interfaces with "*Capable*" in the name here and there in the FOSS world (but not in the JRE) so I am a little more comfortable with it. 
> 
> I still see plain old "Shutdown" as simpler. 
> 
> I think I've boiled down my feel for this name to the fact that the Capable postfix is redundant since a class implementing any interface is "capable" of that functionality. IOW we have Serializable vs. SerializationCabable, which means the same thing.
> 
> Gary
> 
> On Mon, Jan 25, 2016 at 7:27 AM, Ralph Goers <ralph.goers@dslextreme.com <ma...@dslextreme.com>> wrote:
> What does it feel weird to you?  To be honest, I originally named the interface ‘Shutdown” and then changed it since it really is about implementing a behavior and “Shutdown” alone doesn’t really describe that.
> 
> Ralph
> 
>> On Jan 24, 2016, at 11:09 PM, Gary Gregory <garydgregory@gmail.com <ma...@gmail.com>> wrote:
>> 
>> On Sun, Jan 24, 2016 at 10:07 PM, Gary Gregory <garydgregory@gmail.com <ma...@gmail.com>> wrote:
>> On Sun, Jan 24, 2016 at 1:54 PM, Ralph Goers <ralph.goers@dslextreme.com <ma...@dslextreme.com>> wrote:
>> Yes, Shutdownable is too weird. 
>> 
>> How about calling it simply "Shutdown" then? FooCapable feels weird to me.
>> 
>> Can anyone think of other (one-method or not) optional feature-like interfaces in the JRE or other code base?
>> 
>> hm... ShutdownService?
>> 
>> Gary
>>  
>> 
>> Gary
>> 
>> Closeable would imply there is a close method, not a shutdown method.  I have my doubts about the try-with-resources use case here.  Virtually all usages are probably going to be to disable automatic shutdown and then the user placing the shutdown call somewhere they can control, which probably will have nothing to do with initialization of logging. 
>> 
>> Ralph
>> 
>>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <garydgregory@gmail.com <ma...@gmail.com>> wrote:
>>> 
>>> Resending, got a error from my phone...
>>> 
>>> ---------- Forwarded message ----------
>>> From: "Gary Gregory" <garydgregory@gmail.com <ma...@gmail.com>>
>>> Date: Jan 24, 2016 1:41 PM
>>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager
>>> To: <dev@logging.apache.org <ma...@logging.apache.org>>
>>> Cc: 
>>> 
>>> Hi all,
>>> 
>>> Any reason not use the usual -able postfix instead of ShutdownCapable: Shutdownable sounds too weird? What about reusing plain old Closeable? That means you could use the context in a try-with-resources block, a bonus.
>>> 
>>> Gary 
>>> 
>>> On Jan 24, 2016 10:18 AM, <rgoers@apache.org <ma...@apache.org>> wrote:
>>> Repository: logging-log4j2
>>> Updated Branches:
>>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>>> 
>>> 
>>> LOG4J2-124 - Add shutdown methods to LogManager
>>> 
>>> 
>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo <http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo>
>>> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7>
>>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7>
>>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7>
>>> 
>>> Branch: refs/heads/master
>>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>>> Parents: 7d3aac4
>>> Author: Ralph Goers <rgoers@nextiva.com <ma...@nextiva.com>>
>>> Authored: Sun Jan 24 11:18:41 2016 -0700
>>> Committer: Ralph Goers <rgoers@nextiva.com <ma...@nextiva.com>>
>>> Committed: Sun Jan 24 11:18:41 2016 -0700
>>> 
>>> ----------------------------------------------------------------------
>>>  .../org/apache/logging/log4j/LogManager.java    | 62 ++++++++++++++++++++
>>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>>  4 files changed, 93 insertions(+), 1 deletion(-)
>>> ----------------------------------------------------------------------
>>> 
>>> 
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java>
>>> ----------------------------------------------------------------------
>>> diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> index f10e5a8..64c6ee5 100644
>>> --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> @@ -27,6 +27,7 @@ import org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>>  import org.apache.logging.log4j.spi.LoggerContext;
>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>  import org.apache.logging.log4j.spi.Provider;
>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>  import org.apache.logging.log4j.status.StatusLogger;
>>>  import org.apache.logging.log4j.util.LoaderUtil;
>>>  import org.apache.logging.log4j.util.PropertiesUtil;
>>> @@ -285,6 +286,67 @@ public class LogManager {
>>>      }
>>> 
>>>      /**
>>> +     * Shutdown using the default LoggerContext.
>>> +     * @since 2.6
>>> +     */
>>> +    public static void shutdown() {
>>> +        shutdown(getContext());
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param currentContext if true the LoggerContext for the caller of this method will be used.
>>> +     * @since 2.6
>>> +     */
>>> +    public static void shutdown(boolean currentContext) {
>>> +        shutdown(getContext(currentContext));
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param loader The ClassLoader for the context. If null the context will attempt to determine the appropriate
>>> +     *            ClassLoader.
>>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>>> +     * @since 2.6
>>> +     */
>>> +    public static void shutdown(final ClassLoader loader, final boolean currentContext) {
>>> +        shutdown(getContext(loader, currentContext));
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param context the LoggerContext.
>>> +     * @since 2.6
>>> +     */
>>> +    public static void shutdown(LoggerContext context) {
>>> +        if (context != null && context instanceof ShutdownCapable) {
>>> +            ((ShutdownCapable) context).shutdown();
>>> +        }
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param fqcn The fully qualified class name of the Class that this method is a member of.
>>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>>> +     * @since 2.6
>>> +     */
>>> +    protected static void shutdown(final String fqcn, final boolean currentContext) {
>>> +        shutdown(getContext(fqcn, currentContext));
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param fqcn The fully qualified class name of the Class that this method is a member of.
>>> +     * @param loader The ClassLoader for the context. If null the context will attempt to determine the appropriate
>>> +     *            ClassLoader.
>>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>>> +     * @since 2.6
>>> +     */
>>> +    protected static void shutdown(final String fqcn, final ClassLoader loader, final boolean currentContext) {
>>> +        shutdown(getContext(fqcn, loader, currentContext));
>>> +    }
>>> +
>>> +    /**
>>>       * Returns the current LoggerContextFactory.
>>>       *
>>>       * @return The LoggerContextFactory.
>>> 
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java>
>>> ----------------------------------------------------------------------
>>> diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>> new file mode 100644
>>> index 0000000..a46ef60
>>> --- /dev/null
>>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>> @@ -0,0 +1,17 @@
>>> +/*
>>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>>> + * All rights reserved.
>>> + */
>>> +package org.apache.logging.log4j.spi;
>>> +
>>> +/**
>>> + * Interface to be implemented by LoggerContext's that provide a shutdown method.
>>> + * @since 2.6
>>> + */
>>> +public interface ShutdownCapable {
>>> +
>>> +    /**
>>> +     * Requests that the logging implementation shut down.
>>> +     */
>>> +    void shutdown();
>>> +}
>>> 
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java>
>>> ----------------------------------------------------------------------
>>> diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> index 48f0eea..596a9f2 100644
>>> --- a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> +++ b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> @@ -17,6 +17,7 @@
>>>  package org.apache.logging.log4j;
>>> 
>>>  import org.apache.logging.log4j.message.ParameterizedMessageFactory;
>>> +import org.apache.logging.log4j.spi.LoggerContext;
>>>  import org.junit.Test;
>>> 
>>>  import static org.junit.Assert.*;
>>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>>          assertNotNull("No Logger returned", logger);
>>>          assertTrue("Incorrect Logger name: " + logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>>      }
>>> +
>>> +    @Test
>>> +    public void testShutdown() {
>>> +        LoggerContext loggerContext = LogManager.getContext(false);
>>> +        LogManager.shutdown(loggerContext);
>>> +    }
>>>  }
>>> 
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java>
>>> ----------------------------------------------------------------------
>>> diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> index 42efbb5..fcdfc16 100644
>>> --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> @@ -45,6 +45,7 @@ import org.apache.logging.log4j.message.MessageFactory;
>>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>> 
>>>  import static org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>> 
>>> @@ -54,7 +55,7 @@ import static org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>   * filters, etc and will be atomically updated whenever a reconfigure occurs.
>>>   */
>>>  public class LoggerContext extends AbstractLifeCycle implements org.apache.logging.log4j.spi.LoggerContext,
>>> -        ConfigurationListener {
>>> +        ShutdownCapable, ConfigurationListener {
>>> 
>>>      /**
>>>       * Property name of the property change event fired if the configuration is changed.
>>> @@ -278,6 +279,11 @@ public class LoggerContext extends AbstractLifeCycle implements org.apache.loggi
>>>      }
>>> 
>>>      @Override
>>> +    public void shutdown() {
>>> +        stop();
>>> +    }
>>> +
>>> +    @Override
>>>      public void stop() {
>>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...", getName(), this);
>>>          configLock.lock();
>>> 
>> 
>> 
>> 
>> 
>> -- 
>> E-Mail: garydgregory@gmail.com <ma...@gmail.com> | ggregory@apache.org  <ma...@apache.org>
>> Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> 
>> Home: http://garygregory.com/ <http://garygregory.com/>
>> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>
>> 
>> 
>> -- 
>> E-Mail: garydgregory@gmail.com <ma...@gmail.com> | ggregory@apache.org  <ma...@apache.org>
>> Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> 
>> Home: http://garygregory.com/ <http://garygregory.com/>
>> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>
> 
> 
> 
> -- 
> E-Mail: garydgregory@gmail.com <ma...@gmail.com> | ggregory@apache.org  <ma...@apache.org>
> Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> 
> Home: http://garygregory.com/ <http://garygregory.com/>
> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>

Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Gary Gregory <ga...@gmail.com>.
I see some interfaces with "*Capable*" in the name here and there in the
FOSS world (but not in the JRE) so I am a little more comfortable with it.

I still see plain old "Shutdown" as simpler.

I think I've boiled down my feel for this name to the fact that the Capable
postfix is redundant since a class implementing any interface is "capable"
of that functionality. IOW we have Serializable vs. SerializationCabable,
which means the same thing.

Gary

On Mon, Jan 25, 2016 at 7:27 AM, Ralph Goers <ra...@dslextreme.com>
wrote:

> What does it feel weird to you?  To be honest, I originally named the
> interface ‘Shutdown” and then changed it since it really is about
> implementing a behavior and “Shutdown” alone doesn’t really describe that.
>
> Ralph
>
> On Jan 24, 2016, at 11:09 PM, Gary Gregory <ga...@gmail.com> wrote:
>
> On Sun, Jan 24, 2016 at 10:07 PM, Gary Gregory <ga...@gmail.com>
> wrote:
>
>> On Sun, Jan 24, 2016 at 1:54 PM, Ralph Goers <ra...@dslextreme.com>
>>  wrote:
>>
>>> Yes, Shutdownable is too weird.
>>>
>>
>> How about calling it simply "Shutdown" then? FooCapable feels weird to me.
>>
>> Can anyone think of other (one-method or not) optional feature-like
>> interfaces in the JRE or other code base?
>>
>
> hm... ShutdownService?
>
> Gary
>
>
>>
>> Gary
>>
>> Closeable would imply there is a close method, not a shutdown method.  I
>>> have my doubts about the try-with-resources use case here.  Virtually all
>>> usages are probably going to be to disable automatic shutdown and then the
>>> user placing the shutdown call somewhere they can control, which probably
>>> will have nothing to do with initialization of logging.
>>>
>>> Ralph
>>>
>>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <ga...@gmail.com>
>>> wrote:
>>>
>>> Resending, got a error from my phone...
>>> ---------- Forwarded message ----------
>>> From: "Gary Gregory" <ga...@gmail.com>
>>> Date: Jan 24, 2016 1:41 PM
>>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown
>>> methods to LogManager
>>> To: <de...@logging.apache.org>
>>> Cc:
>>>
>>> Hi all,
>>>
>>> Any reason not use the usual -able postfix instead of ShutdownCapable:
>>> Shutdownable sounds too weird? What about reusing plain old Closeable? That
>>> means you could use the context in a try-with-resources block, a bonus.
>>>
>>> Gary
>>> On Jan 24, 2016 10:18 AM, <rg...@apache.org> wrote:
>>>
>>>> Repository: logging-log4j2
>>>> Updated Branches:
>>>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>>>>
>>>>
>>>> LOG4J2-124 - Add shutdown methods to LogManager
>>>>
>>>>
>>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>>> Commit:
>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7
>>>> Tree:
>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7
>>>> Diff:
>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7
>>>>
>>>> Branch: refs/heads/master
>>>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>>>> Parents: 7d3aac4
>>>> Author: Ralph Goers <rg...@nextiva.com>
>>>> Authored: Sun Jan 24 11:18:41 2016 -0700
>>>> Committer: Ralph Goers <rg...@nextiva.com>
>>>> Committed: Sun Jan 24 11:18:41 2016 -0700
>>>>
>>>> ----------------------------------------------------------------------
>>>>  .../org/apache/logging/log4j/LogManager.java    | 62
>>>> ++++++++++++++++++++
>>>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>>>  4 files changed, 93 insertions(+), 1 deletion(-)
>>>> ----------------------------------------------------------------------
>>>>
>>>>
>>>>
>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>> ----------------------------------------------------------------------
>>>> diff --git
>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>> index f10e5a8..64c6ee5 100644
>>>> --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>> @@ -27,6 +27,7 @@ import
>>>> org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>>>  import org.apache.logging.log4j.spi.LoggerContext;
>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>  import org.apache.logging.log4j.spi.Provider;
>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>  import org.apache.logging.log4j.status.StatusLogger;
>>>>  import org.apache.logging.log4j.util.LoaderUtil;
>>>>  import org.apache.logging.log4j.util.PropertiesUtil;
>>>> @@ -285,6 +286,67 @@ public class LogManager {
>>>>      }
>>>>
>>>>      /**
>>>> +     * Shutdown using the default LoggerContext.
>>>> +     * @since 2.6
>>>> +     */
>>>> +    public static void shutdown() {
>>>> +        shutdown(getContext());
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Shutdown the logging system if the logging system supports it.
>>>> +     * @param currentContext if true the LoggerContext for the caller
>>>> of this method will be used.
>>>> +     * @since 2.6
>>>> +     */
>>>> +    public static void shutdown(boolean currentContext) {
>>>> +        shutdown(getContext(currentContext));
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Shutdown the logging system if the logging system supports it.
>>>> +     * @param loader The ClassLoader for the context. If null the
>>>> context will attempt to determine the appropriate
>>>> +     *            ClassLoader.
>>>> +     * @param currentContext if false the LoggerContext appropriate
>>>> for the caller of this method will be used.
>>>> +     * @since 2.6
>>>> +     */
>>>> +    public static void shutdown(final ClassLoader loader, final
>>>> boolean currentContext) {
>>>> +        shutdown(getContext(loader, currentContext));
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Shutdown the logging system if the logging system supports it.
>>>> +     * @param context the LoggerContext.
>>>> +     * @since 2.6
>>>> +     */
>>>> +    public static void shutdown(LoggerContext context) {
>>>> +        if (context != null && context instanceof ShutdownCapable) {
>>>> +            ((ShutdownCapable) context).shutdown();
>>>> +        }
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Shutdown the logging system if the logging system supports it.
>>>> +     * @param fqcn The fully qualified class name of the Class that
>>>> this method is a member of.
>>>> +     * @param currentContext if false the LoggerContext appropriate
>>>> for the caller of this method will be used.
>>>> +     * @since 2.6
>>>> +     */
>>>> +    protected static void shutdown(final String fqcn, final boolean
>>>> currentContext) {
>>>> +        shutdown(getContext(fqcn, currentContext));
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Shutdown the logging system if the logging system supports it.
>>>> +     * @param fqcn The fully qualified class name of the Class that
>>>> this method is a member of.
>>>> +     * @param loader The ClassLoader for the context. If null the
>>>> context will attempt to determine the appropriate
>>>> +     *            ClassLoader.
>>>> +     * @param currentContext if false the LoggerContext appropriate
>>>> for the caller of this method will be used.
>>>> +     * @since 2.6
>>>> +     */
>>>> +    protected static void shutdown(final String fqcn, final
>>>> ClassLoader loader, final boolean currentContext) {
>>>> +        shutdown(getContext(fqcn, loader, currentContext));
>>>> +    }
>>>> +
>>>> +    /**
>>>>       * Returns the current LoggerContextFactory.
>>>>       *
>>>>       * @return The LoggerContextFactory.
>>>>
>>>>
>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>> ----------------------------------------------------------------------
>>>> diff --git
>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>> new file mode 100644
>>>> index 0000000..a46ef60
>>>> --- /dev/null
>>>> +++
>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>> @@ -0,0 +1,17 @@
>>>> +/*
>>>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>>>> + * All rights reserved.
>>>> + */
>>>> +package org.apache.logging.log4j.spi;
>>>> +
>>>> +/**
>>>> + * Interface to be implemented by LoggerContext's that provide a
>>>> shutdown method.
>>>> + * @since 2.6
>>>> + */
>>>> +public interface ShutdownCapable {
>>>> +
>>>> +    /**
>>>> +     * Requests that the logging implementation shut down.
>>>> +     */
>>>> +    void shutdown();
>>>> +}
>>>>
>>>>
>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>> ----------------------------------------------------------------------
>>>> diff --git
>>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>> index 48f0eea..596a9f2 100644
>>>> ---
>>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>> +++
>>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>> @@ -17,6 +17,7 @@
>>>>  package org.apache.logging.log4j;
>>>>
>>>>  import org.apache.logging.log4j.message.ParameterizedMessageFactory;
>>>> +import org.apache.logging.log4j.spi.LoggerContext;
>>>>  import org.junit.Test;
>>>>
>>>>  import static org.junit.Assert.*;
>>>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>>>          assertNotNull("No Logger returned", logger);
>>>>          assertTrue("Incorrect Logger name: " +
>>>> logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>>>      }
>>>> +
>>>> +    @Test
>>>> +    public void testShutdown() {
>>>> +        LoggerContext loggerContext = LogManager.getContext(false);
>>>> +        LogManager.shutdown(loggerContext);
>>>> +    }
>>>>  }
>>>>
>>>>
>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>> ----------------------------------------------------------------------
>>>> diff --git
>>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>> index 42efbb5..fcdfc16 100644
>>>> ---
>>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>> +++
>>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>> @@ -45,6 +45,7 @@ import
>>>> org.apache.logging.log4j.message.MessageFactory;
>>>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>
>>>>  import static
>>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>
>>>> @@ -54,7 +55,7 @@ import static
>>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>   * filters, etc and will be atomically updated whenever a reconfigure
>>>> occurs.
>>>>   */
>>>>  public class LoggerContext extends AbstractLifeCycle implements
>>>> org.apache.logging.log4j.spi.LoggerContext,
>>>> -        ConfigurationListener {
>>>> +        ShutdownCapable, ConfigurationListener {
>>>>
>>>>      /**
>>>>       * Property name of the property change event fired if the
>>>> configuration is changed.
>>>> @@ -278,6 +279,11 @@ public class LoggerContext extends
>>>> AbstractLifeCycle implements org.apache.loggi
>>>>      }
>>>>
>>>>      @Override
>>>> +    public void shutdown() {
>>>> +        stop();
>>>> +    }
>>>> +
>>>> +    @Override
>>>>      public void stop() {
>>>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...",
>>>> getName(), this);
>>>>          configLock.lock();
>>>>
>>>>
>>>
>>
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> <gg...@apache.org>
>> Java Persistence with Hibernate, Second Edition
>> <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
>>
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> <gg...@apache.org>
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Ralph Goers <ra...@dslextreme.com>.
What does it feel weird to you?  To be honest, I originally named the interface ‘Shutdown” and then changed it since it really is about implementing a behavior and “Shutdown” alone doesn’t really describe that.

Ralph

> On Jan 24, 2016, at 11:09 PM, Gary Gregory <ga...@gmail.com> wrote:
> 
> On Sun, Jan 24, 2016 at 10:07 PM, Gary Gregory <garydgregory@gmail.com <ma...@gmail.com>> wrote:
> On Sun, Jan 24, 2016 at 1:54 PM, Ralph Goers <ralph.goers@dslextreme.com <ma...@dslextreme.com>> wrote:
> Yes, Shutdownable is too weird. 
> 
> How about calling it simply "Shutdown" then? FooCapable feels weird to me.
> 
> Can anyone think of other (one-method or not) optional feature-like interfaces in the JRE or other code base?
> 
> hm... ShutdownService?
> 
> Gary
>  
> 
> Gary
> 
> Closeable would imply there is a close method, not a shutdown method.  I have my doubts about the try-with-resources use case here.  Virtually all usages are probably going to be to disable automatic shutdown and then the user placing the shutdown call somewhere they can control, which probably will have nothing to do with initialization of logging. 
> 
> Ralph
> 
>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <garydgregory@gmail.com <ma...@gmail.com>> wrote:
>> 
>> Resending, got a error from my phone...
>> 
>> ---------- Forwarded message ----------
>> From: "Gary Gregory" <garydgregory@gmail.com <ma...@gmail.com>>
>> Date: Jan 24, 2016 1:41 PM
>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager
>> To: <dev@logging.apache.org <ma...@logging.apache.org>>
>> Cc: 
>> 
>> Hi all,
>> 
>> Any reason not use the usual -able postfix instead of ShutdownCapable: Shutdownable sounds too weird? What about reusing plain old Closeable? That means you could use the context in a try-with-resources block, a bonus.
>> 
>> Gary 
>> 
>> On Jan 24, 2016 10:18 AM, <rgoers@apache.org <ma...@apache.org>> wrote:
>> Repository: logging-log4j2
>> Updated Branches:
>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>> 
>> 
>> LOG4J2-124 - Add shutdown methods to LogManager
>> 
>> 
>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo <http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo>
>> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7>
>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7>
>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7>
>> 
>> Branch: refs/heads/master
>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>> Parents: 7d3aac4
>> Author: Ralph Goers <rgoers@nextiva.com <ma...@nextiva.com>>
>> Authored: Sun Jan 24 11:18:41 2016 -0700
>> Committer: Ralph Goers <rgoers@nextiva.com <ma...@nextiva.com>>
>> Committed: Sun Jan 24 11:18:41 2016 -0700
>> 
>> ----------------------------------------------------------------------
>>  .../org/apache/logging/log4j/LogManager.java    | 62 ++++++++++++++++++++
>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>  4 files changed, 93 insertions(+), 1 deletion(-)
>> ----------------------------------------------------------------------
>> 
>> 
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java>
>> ----------------------------------------------------------------------
>> diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>> index f10e5a8..64c6ee5 100644
>> --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>> @@ -27,6 +27,7 @@ import org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>  import org.apache.logging.log4j.spi.LoggerContext;
>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>  import org.apache.logging.log4j.spi.Provider;
>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>  import org.apache.logging.log4j.status.StatusLogger;
>>  import org.apache.logging.log4j.util.LoaderUtil;
>>  import org.apache.logging.log4j.util.PropertiesUtil;
>> @@ -285,6 +286,67 @@ public class LogManager {
>>      }
>> 
>>      /**
>> +     * Shutdown using the default LoggerContext.
>> +     * @since 2.6
>> +     */
>> +    public static void shutdown() {
>> +        shutdown(getContext());
>> +    }
>> +
>> +    /**
>> +     * Shutdown the logging system if the logging system supports it.
>> +     * @param currentContext if true the LoggerContext for the caller of this method will be used.
>> +     * @since 2.6
>> +     */
>> +    public static void shutdown(boolean currentContext) {
>> +        shutdown(getContext(currentContext));
>> +    }
>> +
>> +    /**
>> +     * Shutdown the logging system if the logging system supports it.
>> +     * @param loader The ClassLoader for the context. If null the context will attempt to determine the appropriate
>> +     *            ClassLoader.
>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>> +     * @since 2.6
>> +     */
>> +    public static void shutdown(final ClassLoader loader, final boolean currentContext) {
>> +        shutdown(getContext(loader, currentContext));
>> +    }
>> +
>> +    /**
>> +     * Shutdown the logging system if the logging system supports it.
>> +     * @param context the LoggerContext.
>> +     * @since 2.6
>> +     */
>> +    public static void shutdown(LoggerContext context) {
>> +        if (context != null && context instanceof ShutdownCapable) {
>> +            ((ShutdownCapable) context).shutdown();
>> +        }
>> +    }
>> +
>> +    /**
>> +     * Shutdown the logging system if the logging system supports it.
>> +     * @param fqcn The fully qualified class name of the Class that this method is a member of.
>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>> +     * @since 2.6
>> +     */
>> +    protected static void shutdown(final String fqcn, final boolean currentContext) {
>> +        shutdown(getContext(fqcn, currentContext));
>> +    }
>> +
>> +    /**
>> +     * Shutdown the logging system if the logging system supports it.
>> +     * @param fqcn The fully qualified class name of the Class that this method is a member of.
>> +     * @param loader The ClassLoader for the context. If null the context will attempt to determine the appropriate
>> +     *            ClassLoader.
>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>> +     * @since 2.6
>> +     */
>> +    protected static void shutdown(final String fqcn, final ClassLoader loader, final boolean currentContext) {
>> +        shutdown(getContext(fqcn, loader, currentContext));
>> +    }
>> +
>> +    /**
>>       * Returns the current LoggerContextFactory.
>>       *
>>       * @return The LoggerContextFactory.
>> 
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java>
>> ----------------------------------------------------------------------
>> diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>> new file mode 100644
>> index 0000000..a46ef60
>> --- /dev/null
>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>> @@ -0,0 +1,17 @@
>> +/*
>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>> + * All rights reserved.
>> + */
>> +package org.apache.logging.log4j.spi;
>> +
>> +/**
>> + * Interface to be implemented by LoggerContext's that provide a shutdown method.
>> + * @since 2.6
>> + */
>> +public interface ShutdownCapable {
>> +
>> +    /**
>> +     * Requests that the logging implementation shut down.
>> +     */
>> +    void shutdown();
>> +}
>> 
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java>
>> ----------------------------------------------------------------------
>> diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>> index 48f0eea..596a9f2 100644
>> --- a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>> +++ b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>> @@ -17,6 +17,7 @@
>>  package org.apache.logging.log4j;
>> 
>>  import org.apache.logging.log4j.message.ParameterizedMessageFactory;
>> +import org.apache.logging.log4j.spi.LoggerContext;
>>  import org.junit.Test;
>> 
>>  import static org.junit.Assert.*;
>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>          assertNotNull("No Logger returned", logger);
>>          assertTrue("Incorrect Logger name: " + logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>      }
>> +
>> +    @Test
>> +    public void testShutdown() {
>> +        LoggerContext loggerContext = LogManager.getContext(false);
>> +        LogManager.shutdown(loggerContext);
>> +    }
>>  }
>> 
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java>
>> ----------------------------------------------------------------------
>> diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>> index 42efbb5..fcdfc16 100644
>> --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>> +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>> @@ -45,6 +45,7 @@ import org.apache.logging.log4j.message.MessageFactory;
>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>> 
>>  import static org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>> 
>> @@ -54,7 +55,7 @@ import static org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>   * filters, etc and will be atomically updated whenever a reconfigure occurs.
>>   */
>>  public class LoggerContext extends AbstractLifeCycle implements org.apache.logging.log4j.spi.LoggerContext,
>> -        ConfigurationListener {
>> +        ShutdownCapable, ConfigurationListener {
>> 
>>      /**
>>       * Property name of the property change event fired if the configuration is changed.
>> @@ -278,6 +279,11 @@ public class LoggerContext extends AbstractLifeCycle implements org.apache.loggi
>>      }
>> 
>>      @Override
>> +    public void shutdown() {
>> +        stop();
>> +    }
>> +
>> +    @Override
>>      public void stop() {
>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...", getName(), this);
>>          configLock.lock();
>> 
> 
> 
> 
> 
> -- 
> E-Mail: garydgregory@gmail.com <ma...@gmail.com> | ggregory@apache.org  <ma...@apache.org>
> Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> 
> Home: http://garygregory.com/ <http://garygregory.com/>
> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>
> 
> 
> -- 
> E-Mail: garydgregory@gmail.com <ma...@gmail.com> | ggregory@apache.org  <ma...@apache.org>
> Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> 
> Home: http://garygregory.com/ <http://garygregory.com/>
> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>

Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Gary Gregory <ga...@gmail.com>.
On Sun, Jan 24, 2016 at 10:07 PM, Gary Gregory <ga...@gmail.com>
wrote:

> On Sun, Jan 24, 2016 at 1:54 PM, Ralph Goers <ra...@dslextreme.com>
> wrote:
>
>> Yes, Shutdownable is too weird.
>>
>
> How about calling it simply "Shutdown" then? FooCapable feels weird to me.
>
> Can anyone think of other (one-method or not) optional feature-like
> interfaces in the JRE or other code base?
>

hm... ShutdownService?

Gary


>
> Gary
>
> Closeable would imply there is a close method, not a shutdown method.  I
>> have my doubts about the try-with-resources use case here.  Virtually all
>> usages are probably going to be to disable automatic shutdown and then the
>> user placing the shutdown call somewhere they can control, which probably
>> will have nothing to do with initialization of logging.
>>
>> Ralph
>>
>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <ga...@gmail.com> wrote:
>>
>> Resending, got a error from my phone...
>> ---------- Forwarded message ----------
>> From: "Gary Gregory" <ga...@gmail.com>
>> Date: Jan 24, 2016 1:41 PM
>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods
>> to LogManager
>> To: <de...@logging.apache.org>
>> Cc:
>>
>> Hi all,
>>
>> Any reason not use the usual -able postfix instead of ShutdownCapable:
>> Shutdownable sounds too weird? What about reusing plain old Closeable? That
>> means you could use the context in a try-with-resources block, a bonus.
>>
>> Gary
>> On Jan 24, 2016 10:18 AM, <rg...@apache.org> wrote:
>>
>>> Repository: logging-log4j2
>>> Updated Branches:
>>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>>>
>>>
>>> LOG4J2-124 - Add shutdown methods to LogManager
>>>
>>>
>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>> Commit:
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7
>>> Tree:
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7
>>> Diff:
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7
>>>
>>> Branch: refs/heads/master
>>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>>> Parents: 7d3aac4
>>> Author: Ralph Goers <rg...@nextiva.com>
>>> Authored: Sun Jan 24 11:18:41 2016 -0700
>>> Committer: Ralph Goers <rg...@nextiva.com>
>>> Committed: Sun Jan 24 11:18:41 2016 -0700
>>>
>>> ----------------------------------------------------------------------
>>>  .../org/apache/logging/log4j/LogManager.java    | 62
>>> ++++++++++++++++++++
>>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>>  4 files changed, 93 insertions(+), 1 deletion(-)
>>> ----------------------------------------------------------------------
>>>
>>>
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> ----------------------------------------------------------------------
>>> diff --git
>>> a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> index f10e5a8..64c6ee5 100644
>>> --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> @@ -27,6 +27,7 @@ import
>>> org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>>  import org.apache.logging.log4j.spi.LoggerContext;
>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>  import org.apache.logging.log4j.spi.Provider;
>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>  import org.apache.logging.log4j.status.StatusLogger;
>>>  import org.apache.logging.log4j.util.LoaderUtil;
>>>  import org.apache.logging.log4j.util.PropertiesUtil;
>>> @@ -285,6 +286,67 @@ public class LogManager {
>>>      }
>>>
>>>      /**
>>> +     * Shutdown using the default LoggerContext.
>>> +     * @since 2.6
>>> +     */
>>> +    public static void shutdown() {
>>> +        shutdown(getContext());
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param currentContext if true the LoggerContext for the caller
>>> of this method will be used.
>>> +     * @since 2.6
>>> +     */
>>> +    public static void shutdown(boolean currentContext) {
>>> +        shutdown(getContext(currentContext));
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param loader The ClassLoader for the context. If null the
>>> context will attempt to determine the appropriate
>>> +     *            ClassLoader.
>>> +     * @param currentContext if false the LoggerContext appropriate for
>>> the caller of this method will be used.
>>> +     * @since 2.6
>>> +     */
>>> +    public static void shutdown(final ClassLoader loader, final boolean
>>> currentContext) {
>>> +        shutdown(getContext(loader, currentContext));
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param context the LoggerContext.
>>> +     * @since 2.6
>>> +     */
>>> +    public static void shutdown(LoggerContext context) {
>>> +        if (context != null && context instanceof ShutdownCapable) {
>>> +            ((ShutdownCapable) context).shutdown();
>>> +        }
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param fqcn The fully qualified class name of the Class that
>>> this method is a member of.
>>> +     * @param currentContext if false the LoggerContext appropriate for
>>> the caller of this method will be used.
>>> +     * @since 2.6
>>> +     */
>>> +    protected static void shutdown(final String fqcn, final boolean
>>> currentContext) {
>>> +        shutdown(getContext(fqcn, currentContext));
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param fqcn The fully qualified class name of the Class that
>>> this method is a member of.
>>> +     * @param loader The ClassLoader for the context. If null the
>>> context will attempt to determine the appropriate
>>> +     *            ClassLoader.
>>> +     * @param currentContext if false the LoggerContext appropriate for
>>> the caller of this method will be used.
>>> +     * @since 2.6
>>> +     */
>>> +    protected static void shutdown(final String fqcn, final ClassLoader
>>> loader, final boolean currentContext) {
>>> +        shutdown(getContext(fqcn, loader, currentContext));
>>> +    }
>>> +
>>> +    /**
>>>       * Returns the current LoggerContextFactory.
>>>       *
>>>       * @return The LoggerContextFactory.
>>>
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>> ----------------------------------------------------------------------
>>> diff --git
>>> a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>> new file mode 100644
>>> index 0000000..a46ef60
>>> --- /dev/null
>>> +++
>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>> @@ -0,0 +1,17 @@
>>> +/*
>>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>>> + * All rights reserved.
>>> + */
>>> +package org.apache.logging.log4j.spi;
>>> +
>>> +/**
>>> + * Interface to be implemented by LoggerContext's that provide a
>>> shutdown method.
>>> + * @since 2.6
>>> + */
>>> +public interface ShutdownCapable {
>>> +
>>> +    /**
>>> +     * Requests that the logging implementation shut down.
>>> +     */
>>> +    void shutdown();
>>> +}
>>>
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> ----------------------------------------------------------------------
>>> diff --git
>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> index 48f0eea..596a9f2 100644
>>> ---
>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> +++
>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> @@ -17,6 +17,7 @@
>>>  package org.apache.logging.log4j;
>>>
>>>  import org.apache.logging.log4j.message.ParameterizedMessageFactory;
>>> +import org.apache.logging.log4j.spi.LoggerContext;
>>>  import org.junit.Test;
>>>
>>>  import static org.junit.Assert.*;
>>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>>          assertNotNull("No Logger returned", logger);
>>>          assertTrue("Incorrect Logger name: " +
>>> logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>>      }
>>> +
>>> +    @Test
>>> +    public void testShutdown() {
>>> +        LoggerContext loggerContext = LogManager.getContext(false);
>>> +        LogManager.shutdown(loggerContext);
>>> +    }
>>>  }
>>>
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> ----------------------------------------------------------------------
>>> diff --git
>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> index 42efbb5..fcdfc16 100644
>>> ---
>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> +++
>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> @@ -45,6 +45,7 @@ import org.apache.logging.log4j.message.MessageFactory;
>>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>
>>>  import static
>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>
>>> @@ -54,7 +55,7 @@ import static
>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>   * filters, etc and will be atomically updated whenever a reconfigure
>>> occurs.
>>>   */
>>>  public class LoggerContext extends AbstractLifeCycle implements
>>> org.apache.logging.log4j.spi.LoggerContext,
>>> -        ConfigurationListener {
>>> +        ShutdownCapable, ConfigurationListener {
>>>
>>>      /**
>>>       * Property name of the property change event fired if the
>>> configuration is changed.
>>> @@ -278,6 +279,11 @@ public class LoggerContext extends
>>> AbstractLifeCycle implements org.apache.loggi
>>>      }
>>>
>>>      @Override
>>> +    public void shutdown() {
>>> +        stop();
>>> +    }
>>> +
>>> +    @Override
>>>      public void stop() {
>>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...",
>>> getName(), this);
>>>          configLock.lock();
>>>
>>>
>>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Gary Gregory <ga...@gmail.com>.
On Sun, Jan 24, 2016 at 1:54 PM, Ralph Goers <ra...@dslextreme.com>
wrote:

> Yes, Shutdownable is too weird.
>

How about calling it simply "Shutdown" then? FooCapable feels weird to me.

Can anyone think of other (one-method or not) optional feature-like
interfaces in the JRE or other code base?

Gary

Closeable would imply there is a close method, not a shutdown method.  I
> have my doubts about the try-with-resources use case here.  Virtually all
> usages are probably going to be to disable automatic shutdown and then the
> user placing the shutdown call somewhere they can control, which probably
> will have nothing to do with initialization of logging.
>
> Ralph
>
> On Jan 24, 2016, at 2:43 PM, Gary Gregory <ga...@gmail.com> wrote:
>
> Resending, got a error from my phone...
> ---------- Forwarded message ----------
> From: "Gary Gregory" <ga...@gmail.com>
> Date: Jan 24, 2016 1:41 PM
> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods
> to LogManager
> To: <de...@logging.apache.org>
> Cc:
>
> Hi all,
>
> Any reason not use the usual -able postfix instead of ShutdownCapable:
> Shutdownable sounds too weird? What about reusing plain old Closeable? That
> means you could use the context in a try-with-resources block, a bonus.
>
> Gary
> On Jan 24, 2016 10:18 AM, <rg...@apache.org> wrote:
>
>> Repository: logging-log4j2
>> Updated Branches:
>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>>
>>
>> LOG4J2-124 - Add shutdown methods to LogManager
>>
>>
>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>> Commit:
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7
>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7
>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7
>>
>> Branch: refs/heads/master
>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>> Parents: 7d3aac4
>> Author: Ralph Goers <rg...@nextiva.com>
>> Authored: Sun Jan 24 11:18:41 2016 -0700
>> Committer: Ralph Goers <rg...@nextiva.com>
>> Committed: Sun Jan 24 11:18:41 2016 -0700
>>
>> ----------------------------------------------------------------------
>>  .../org/apache/logging/log4j/LogManager.java    | 62 ++++++++++++++++++++
>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>  4 files changed, 93 insertions(+), 1 deletion(-)
>> ----------------------------------------------------------------------
>>
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>> b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>> index f10e5a8..64c6ee5 100644
>> --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>> @@ -27,6 +27,7 @@ import
>> org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>  import org.apache.logging.log4j.spi.LoggerContext;
>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>  import org.apache.logging.log4j.spi.Provider;
>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>  import org.apache.logging.log4j.status.StatusLogger;
>>  import org.apache.logging.log4j.util.LoaderUtil;
>>  import org.apache.logging.log4j.util.PropertiesUtil;
>> @@ -285,6 +286,67 @@ public class LogManager {
>>      }
>>
>>      /**
>> +     * Shutdown using the default LoggerContext.
>> +     * @since 2.6
>> +     */
>> +    public static void shutdown() {
>> +        shutdown(getContext());
>> +    }
>> +
>> +    /**
>> +     * Shutdown the logging system if the logging system supports it.
>> +     * @param currentContext if true the LoggerContext for the caller of
>> this method will be used.
>> +     * @since 2.6
>> +     */
>> +    public static void shutdown(boolean currentContext) {
>> +        shutdown(getContext(currentContext));
>> +    }
>> +
>> +    /**
>> +     * Shutdown the logging system if the logging system supports it.
>> +     * @param loader The ClassLoader for the context. If null the
>> context will attempt to determine the appropriate
>> +     *            ClassLoader.
>> +     * @param currentContext if false the LoggerContext appropriate for
>> the caller of this method will be used.
>> +     * @since 2.6
>> +     */
>> +    public static void shutdown(final ClassLoader loader, final boolean
>> currentContext) {
>> +        shutdown(getContext(loader, currentContext));
>> +    }
>> +
>> +    /**
>> +     * Shutdown the logging system if the logging system supports it.
>> +     * @param context the LoggerContext.
>> +     * @since 2.6
>> +     */
>> +    public static void shutdown(LoggerContext context) {
>> +        if (context != null && context instanceof ShutdownCapable) {
>> +            ((ShutdownCapable) context).shutdown();
>> +        }
>> +    }
>> +
>> +    /**
>> +     * Shutdown the logging system if the logging system supports it.
>> +     * @param fqcn The fully qualified class name of the Class that this
>> method is a member of.
>> +     * @param currentContext if false the LoggerContext appropriate for
>> the caller of this method will be used.
>> +     * @since 2.6
>> +     */
>> +    protected static void shutdown(final String fqcn, final boolean
>> currentContext) {
>> +        shutdown(getContext(fqcn, currentContext));
>> +    }
>> +
>> +    /**
>> +     * Shutdown the logging system if the logging system supports it.
>> +     * @param fqcn The fully qualified class name of the Class that this
>> method is a member of.
>> +     * @param loader The ClassLoader for the context. If null the
>> context will attempt to determine the appropriate
>> +     *            ClassLoader.
>> +     * @param currentContext if false the LoggerContext appropriate for
>> the caller of this method will be used.
>> +     * @since 2.6
>> +     */
>> +    protected static void shutdown(final String fqcn, final ClassLoader
>> loader, final boolean currentContext) {
>> +        shutdown(getContext(fqcn, loader, currentContext));
>> +    }
>> +
>> +    /**
>>       * Returns the current LoggerContextFactory.
>>       *
>>       * @return The LoggerContextFactory.
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>> new file mode 100644
>> index 0000000..a46ef60
>> --- /dev/null
>> +++
>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>> @@ -0,0 +1,17 @@
>> +/*
>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>> + * All rights reserved.
>> + */
>> +package org.apache.logging.log4j.spi;
>> +
>> +/**
>> + * Interface to be implemented by LoggerContext's that provide a
>> shutdown method.
>> + * @since 2.6
>> + */
>> +public interface ShutdownCapable {
>> +
>> +    /**
>> +     * Requests that the logging implementation shut down.
>> +     */
>> +    void shutdown();
>> +}
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>> index 48f0eea..596a9f2 100644
>> --- a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>> +++ b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>> @@ -17,6 +17,7 @@
>>  package org.apache.logging.log4j;
>>
>>  import org.apache.logging.log4j.message.ParameterizedMessageFactory;
>> +import org.apache.logging.log4j.spi.LoggerContext;
>>  import org.junit.Test;
>>
>>  import static org.junit.Assert.*;
>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>          assertNotNull("No Logger returned", logger);
>>          assertTrue("Incorrect Logger name: " +
>> logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>      }
>> +
>> +    @Test
>> +    public void testShutdown() {
>> +        LoggerContext loggerContext = LogManager.getContext(false);
>> +        LogManager.shutdown(loggerContext);
>> +    }
>>  }
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>> index 42efbb5..fcdfc16 100644
>> ---
>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>> +++
>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>> @@ -45,6 +45,7 @@ import org.apache.logging.log4j.message.MessageFactory;
>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>
>>  import static
>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>
>> @@ -54,7 +55,7 @@ import static
>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>   * filters, etc and will be atomically updated whenever a reconfigure
>> occurs.
>>   */
>>  public class LoggerContext extends AbstractLifeCycle implements
>> org.apache.logging.log4j.spi.LoggerContext,
>> -        ConfigurationListener {
>> +        ShutdownCapable, ConfigurationListener {
>>
>>      /**
>>       * Property name of the property change event fired if the
>> configuration is changed.
>> @@ -278,6 +279,11 @@ public class LoggerContext extends AbstractLifeCycle
>> implements org.apache.loggi
>>      }
>>
>>      @Override
>> +    public void shutdown() {
>> +        stop();
>> +    }
>> +
>> +    @Override
>>      public void stop() {
>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...",
>> getName(), this);
>>          configLock.lock();
>>
>>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Gary Gregory <ga...@gmail.com>.
On Sun, Jan 24, 2016 at 7:07 PM, Ralph Goers <ra...@dslextreme.com>
wrote:

> Actually I would also like to remove shutdown(). It calls getContext()
> which most of the time is not what a user wants. I fear they may call that
> method and then be surprised when it doesn’t do anything.
>

Yeah, let's not surprise folks.

G

>
> Ralph
>
> On Jan 24, 2016, at 3:43 PM, Remko Popma <re...@gmail.com> wrote:
>
> Do we need all 6 methods?
>
> I like the first three:
> * shutdown()
> * shutdown(boolean)
> * shutdown(LoggerContext)
>
> I would argue that the next three are rare use cases. When needed these
> can be accomplished by calling
> LogManager.shutdown(LogManager.getContext(some params)).
>
> I would be in favor of removing these three convenience methods:
> * shutdown(String, boolean)
> * shutdown(String, ClassLoader, boolean)
> * shutdown(ClassLoader, boolean)
>
> Thoughts? -Remko
>
>
> On Mon, Jan 25, 2016 at 6:54 AM, Ralph Goers <ra...@dslextreme.com>
> wrote:
>
>> Yes, Shutdownable is too weird. Closeable would imply there is a close
>> method, not a shutdown method.  I have my doubts about the
>> try-with-resources use case here.  Virtually all usages are probably going
>> to be to disable automatic shutdown and then the user placing the shutdown
>> call somewhere they can control, which probably will have nothing to do
>> with initialization of logging.
>>
>> Ralph
>>
>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <ga...@gmail.com> wrote:
>>
>> Resending, got a error from my phone...
>> ---------- Forwarded message ----------
>> From: "Gary Gregory" <ga...@gmail.com>
>> Date: Jan 24, 2016 1:41 PM
>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods
>> to LogManager
>> To: <de...@logging.apache.org>
>> Cc:
>>
>> Hi all,
>>
>> Any reason not use the usual -able postfix instead of ShutdownCapable:
>> Shutdownable sounds too weird? What about reusing plain old Closeable? That
>> means you could use the context in a try-with-resources block, a bonus.
>>
>> Gary
>> On Jan 24, 2016 10:18 AM, <rg...@apache.org> wrote:
>>
>>> Repository: logging-log4j2
>>> Updated Branches:
>>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>>>
>>>
>>> LOG4J2-124 - Add shutdown methods to LogManager
>>>
>>>
>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>> Commit:
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7
>>> Tree:
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7
>>> Diff:
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7
>>>
>>> Branch: refs/heads/master
>>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>>> Parents: 7d3aac4
>>> Author: Ralph Goers <rg...@nextiva.com>
>>> Authored: Sun Jan 24 11:18:41 2016 -0700
>>> Committer: Ralph Goers <rg...@nextiva.com>
>>> Committed: Sun Jan 24 11:18:41 2016 -0700
>>>
>>> ----------------------------------------------------------------------
>>>  .../org/apache/logging/log4j/LogManager.java    | 62
>>> ++++++++++++++++++++
>>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>>  4 files changed, 93 insertions(+), 1 deletion(-)
>>> ----------------------------------------------------------------------
>>>
>>>
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> ----------------------------------------------------------------------
>>> diff --git
>>> a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> index f10e5a8..64c6ee5 100644
>>> --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> @@ -27,6 +27,7 @@ import
>>> org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>>  import org.apache.logging.log4j.spi.LoggerContext;
>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>  import org.apache.logging.log4j.spi.Provider;
>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>  import org.apache.logging.log4j.status.StatusLogger;
>>>  import org.apache.logging.log4j.util.LoaderUtil;
>>>  import org.apache.logging.log4j.util.PropertiesUtil;
>>> @@ -285,6 +286,67 @@ public class LogManager {
>>>      }
>>>
>>>      /**
>>> +     * Shutdown using the default LoggerContext.
>>> +     * @since 2.6
>>> +     */
>>> +    public static void shutdown() {
>>> +        shutdown(getContext());
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param currentContext if true the LoggerContext for the caller
>>> of this method will be used.
>>> +     * @since 2.6
>>> +     */
>>> +    public static void shutdown(boolean currentContext) {
>>> +        shutdown(getContext(currentContext));
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param loader The ClassLoader for the context. If null the
>>> context will attempt to determine the appropriate
>>> +     *            ClassLoader.
>>> +     * @param currentContext if false the LoggerContext appropriate for
>>> the caller of this method will be used.
>>> +     * @since 2.6
>>> +     */
>>> +    public static void shutdown(final ClassLoader loader, final boolean
>>> currentContext) {
>>> +        shutdown(getContext(loader, currentContext));
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param context the LoggerContext.
>>> +     * @since 2.6
>>> +     */
>>> +    public static void shutdown(LoggerContext context) {
>>> +        if (context != null && context instanceof ShutdownCapable) {
>>> +            ((ShutdownCapable) context).shutdown();
>>> +        }
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param fqcn The fully qualified class name of the Class that
>>> this method is a member of.
>>> +     * @param currentContext if false the LoggerContext appropriate for
>>> the caller of this method will be used.
>>> +     * @since 2.6
>>> +     */
>>> +    protected static void shutdown(final String fqcn, final boolean
>>> currentContext) {
>>> +        shutdown(getContext(fqcn, currentContext));
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param fqcn The fully qualified class name of the Class that
>>> this method is a member of.
>>> +     * @param loader The ClassLoader for the context. If null the
>>> context will attempt to determine the appropriate
>>> +     *            ClassLoader.
>>> +     * @param currentContext if false the LoggerContext appropriate for
>>> the caller of this method will be used.
>>> +     * @since 2.6
>>> +     */
>>> +    protected static void shutdown(final String fqcn, final ClassLoader
>>> loader, final boolean currentContext) {
>>> +        shutdown(getContext(fqcn, loader, currentContext));
>>> +    }
>>> +
>>> +    /**
>>>       * Returns the current LoggerContextFactory.
>>>       *
>>>       * @return The LoggerContextFactory.
>>>
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>> ----------------------------------------------------------------------
>>> diff --git
>>> a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>> new file mode 100644
>>> index 0000000..a46ef60
>>> --- /dev/null
>>> +++
>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>> @@ -0,0 +1,17 @@
>>> +/*
>>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>>> + * All rights reserved.
>>> + */
>>> +package org.apache.logging.log4j.spi;
>>> +
>>> +/**
>>> + * Interface to be implemented by LoggerContext's that provide a
>>> shutdown method.
>>> + * @since 2.6
>>> + */
>>> +public interface ShutdownCapable {
>>> +
>>> +    /**
>>> +     * Requests that the logging implementation shut down.
>>> +     */
>>> +    void shutdown();
>>> +}
>>>
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> ----------------------------------------------------------------------
>>> diff --git
>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> index 48f0eea..596a9f2 100644
>>> ---
>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> +++
>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> @@ -17,6 +17,7 @@
>>>  package org.apache.logging.log4j;
>>>
>>>  import org.apache.logging.log4j.message.ParameterizedMessageFactory;
>>> +import org.apache.logging.log4j.spi.LoggerContext;
>>>  import org.junit.Test;
>>>
>>>  import static org.junit.Assert.*;
>>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>>          assertNotNull("No Logger returned", logger);
>>>          assertTrue("Incorrect Logger name: " +
>>> logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>>      }
>>> +
>>> +    @Test
>>> +    public void testShutdown() {
>>> +        LoggerContext loggerContext = LogManager.getContext(false);
>>> +        LogManager.shutdown(loggerContext);
>>> +    }
>>>  }
>>>
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> ----------------------------------------------------------------------
>>> diff --git
>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> index 42efbb5..fcdfc16 100644
>>> ---
>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> +++
>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> @@ -45,6 +45,7 @@ import org.apache.logging.log4j.message.MessageFactory;
>>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>
>>>  import static
>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>
>>> @@ -54,7 +55,7 @@ import static
>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>   * filters, etc and will be atomically updated whenever a reconfigure
>>> occurs.
>>>   */
>>>  public class LoggerContext extends AbstractLifeCycle implements
>>> org.apache.logging.log4j.spi.LoggerContext,
>>> -        ConfigurationListener {
>>> +        ShutdownCapable, ConfigurationListener {
>>>
>>>      /**
>>>       * Property name of the property change event fired if the
>>> configuration is changed.
>>> @@ -278,6 +279,11 @@ public class LoggerContext extends
>>> AbstractLifeCycle implements org.apache.loggi
>>>      }
>>>
>>>      @Override
>>> +    public void shutdown() {
>>> +        stop();
>>> +    }
>>> +
>>> +    @Override
>>>      public void stop() {
>>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...",
>>> getName(), this);
>>>          configLock.lock();
>>>
>>>
>>
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Remko Popma <re...@gmail.com>.
I've taken the liberty to make the above changes. Please check that you
agree with the result.

On Mon, Jan 25, 2016 at 3:48 PM, Remko Popma <re...@gmail.com> wrote:

> I actually like the simple shutdown() method, it should just be
> implemented with getContext(false).
>
> Remko
>
>
> On Monday, 25 January 2016, Ralph Goers <ra...@dslextreme.com>
> wrote:
>
>> Actually I would also like to remove shutdown(). It calls getContext()
>> which most of the time is not what a user wants. I fear they may call that
>> method and then be surprised when it doesn’t do anything.
>>
>> Ralph
>>
>> On Jan 24, 2016, at 3:43 PM, Remko Popma <re...@gmail.com> wrote:
>>
>> Do we need all 6 methods?
>>
>> I like the first three:
>> * shutdown()
>> * shutdown(boolean)
>> * shutdown(LoggerContext)
>>
>> I would argue that the next three are rare use cases. When needed these
>> can be accomplished by calling
>> LogManager.shutdown(LogManager.getContext(some params)).
>>
>> I would be in favor of removing these three convenience methods:
>> * shutdown(String, boolean)
>> * shutdown(String, ClassLoader, boolean)
>> * shutdown(ClassLoader, boolean)
>>
>> Thoughts? -Remko
>>
>>
>> On Mon, Jan 25, 2016 at 6:54 AM, Ralph Goers <ra...@dslextreme.com>
>> wrote:
>>
>>> Yes, Shutdownable is too weird. Closeable would imply there is a close
>>> method, not a shutdown method.  I have my doubts about the
>>> try-with-resources use case here.  Virtually all usages are probably going
>>> to be to disable automatic shutdown and then the user placing the shutdown
>>> call somewhere they can control, which probably will have nothing to do
>>> with initialization of logging.
>>>
>>> Ralph
>>>
>>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <ga...@gmail.com>
>>> wrote:
>>>
>>> Resending, got a error from my phone...
>>> ---------- Forwarded message ----------
>>> From: "Gary Gregory" <ga...@gmail.com>
>>> Date: Jan 24, 2016 1:41 PM
>>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown
>>> methods to LogManager
>>> To: <de...@logging.apache.org>
>>> Cc:
>>>
>>> Hi all,
>>>
>>> Any reason not use the usual -able postfix instead of ShutdownCapable:
>>> Shutdownable sounds too weird? What about reusing plain old Closeable? That
>>> means you could use the context in a try-with-resources block, a bonus.
>>>
>>> Gary
>>> On Jan 24, 2016 10:18 AM, <rg...@apache.org> wrote:
>>>
>>>> Repository: logging-log4j2
>>>> Updated Branches:
>>>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>>>>
>>>>
>>>> LOG4J2-124 - Add shutdown methods to LogManager
>>>>
>>>>
>>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>>> Commit:
>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7
>>>> Tree:
>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7
>>>> Diff:
>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7
>>>>
>>>> Branch: refs/heads/master
>>>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>>>> Parents: 7d3aac4
>>>> Author: Ralph Goers <rg...@nextiva.com>
>>>> Authored: Sun Jan 24 11:18:41 2016 -0700
>>>> Committer: Ralph Goers <rg...@nextiva.com>
>>>> Committed: Sun Jan 24 11:18:41 2016 -0700
>>>>
>>>> ----------------------------------------------------------------------
>>>>  .../org/apache/logging/log4j/LogManager.java    | 62
>>>> ++++++++++++++++++++
>>>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>>>  4 files changed, 93 insertions(+), 1 deletion(-)
>>>> ----------------------------------------------------------------------
>>>>
>>>>
>>>>
>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>> ----------------------------------------------------------------------
>>>> diff --git
>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>> index f10e5a8..64c6ee5 100644
>>>> --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>>> @@ -27,6 +27,7 @@ import
>>>> org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>>>  import org.apache.logging.log4j.spi.LoggerContext;
>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>  import org.apache.logging.log4j.spi.Provider;
>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>  import org.apache.logging.log4j.status.StatusLogger;
>>>>  import org.apache.logging.log4j.util.LoaderUtil;
>>>>  import org.apache.logging.log4j.util.PropertiesUtil;
>>>> @@ -285,6 +286,67 @@ public class LogManager {
>>>>      }
>>>>
>>>>      /**
>>>> +     * Shutdown using the default LoggerContext.
>>>> +     * @since 2.6
>>>> +     */
>>>> +    public static void shutdown() {
>>>> +        shutdown(getContext());
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Shutdown the logging system if the logging system supports it.
>>>> +     * @param currentContext if true the LoggerContext for the caller
>>>> of this method will be used.
>>>> +     * @since 2.6
>>>> +     */
>>>> +    public static void shutdown(boolean currentContext) {
>>>> +        shutdown(getContext(currentContext));
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Shutdown the logging system if the logging system supports it.
>>>> +     * @param loader The ClassLoader for the context. If null the
>>>> context will attempt to determine the appropriate
>>>> +     *            ClassLoader.
>>>> +     * @param currentContext if false the LoggerContext appropriate
>>>> for the caller of this method will be used.
>>>> +     * @since 2.6
>>>> +     */
>>>> +    public static void shutdown(final ClassLoader loader, final
>>>> boolean currentContext) {
>>>> +        shutdown(getContext(loader, currentContext));
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Shutdown the logging system if the logging system supports it.
>>>> +     * @param context the LoggerContext.
>>>> +     * @since 2.6
>>>> +     */
>>>> +    public static void shutdown(LoggerContext context) {
>>>> +        if (context != null && context instanceof ShutdownCapable) {
>>>> +            ((ShutdownCapable) context).shutdown();
>>>> +        }
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Shutdown the logging system if the logging system supports it.
>>>> +     * @param fqcn The fully qualified class name of the Class that
>>>> this method is a member of.
>>>> +     * @param currentContext if false the LoggerContext appropriate
>>>> for the caller of this method will be used.
>>>> +     * @since 2.6
>>>> +     */
>>>> +    protected static void shutdown(final String fqcn, final boolean
>>>> currentContext) {
>>>> +        shutdown(getContext(fqcn, currentContext));
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Shutdown the logging system if the logging system supports it.
>>>> +     * @param fqcn The fully qualified class name of the Class that
>>>> this method is a member of.
>>>> +     * @param loader The ClassLoader for the context. If null the
>>>> context will attempt to determine the appropriate
>>>> +     *            ClassLoader.
>>>> +     * @param currentContext if false the LoggerContext appropriate
>>>> for the caller of this method will be used.
>>>> +     * @since 2.6
>>>> +     */
>>>> +    protected static void shutdown(final String fqcn, final
>>>> ClassLoader loader, final boolean currentContext) {
>>>> +        shutdown(getContext(fqcn, loader, currentContext));
>>>> +    }
>>>> +
>>>> +    /**
>>>>       * Returns the current LoggerContextFactory.
>>>>       *
>>>>       * @return The LoggerContextFactory.
>>>>
>>>>
>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>> ----------------------------------------------------------------------
>>>> diff --git
>>>> a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>> new file mode 100644
>>>> index 0000000..a46ef60
>>>> --- /dev/null
>>>> +++
>>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>>> @@ -0,0 +1,17 @@
>>>> +/*
>>>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>>>> + * All rights reserved.
>>>> + */
>>>> +package org.apache.logging.log4j.spi;
>>>> +
>>>> +/**
>>>> + * Interface to be implemented by LoggerContext's that provide a
>>>> shutdown method.
>>>> + * @since 2.6
>>>> + */
>>>> +public interface ShutdownCapable {
>>>> +
>>>> +    /**
>>>> +     * Requests that the logging implementation shut down.
>>>> +     */
>>>> +    void shutdown();
>>>> +}
>>>>
>>>>
>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>> ----------------------------------------------------------------------
>>>> diff --git
>>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>> index 48f0eea..596a9f2 100644
>>>> ---
>>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>> +++
>>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>>> @@ -17,6 +17,7 @@
>>>>  package org.apache.logging.log4j;
>>>>
>>>>  import org.apache.logging.log4j.message.ParameterizedMessageFactory;
>>>> +import org.apache.logging.log4j.spi.LoggerContext;
>>>>  import org.junit.Test;
>>>>
>>>>  import static org.junit.Assert.*;
>>>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>>>          assertNotNull("No Logger returned", logger);
>>>>          assertTrue("Incorrect Logger name: " +
>>>> logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>>>      }
>>>> +
>>>> +    @Test
>>>> +    public void testShutdown() {
>>>> +        LoggerContext loggerContext = LogManager.getContext(false);
>>>> +        LogManager.shutdown(loggerContext);
>>>> +    }
>>>>  }
>>>>
>>>>
>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>> ----------------------------------------------------------------------
>>>> diff --git
>>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>> index 42efbb5..fcdfc16 100644
>>>> ---
>>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>> +++
>>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>>> @@ -45,6 +45,7 @@ import
>>>> org.apache.logging.log4j.message.MessageFactory;
>>>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>>
>>>>  import static
>>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>
>>>> @@ -54,7 +55,7 @@ import static
>>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>>   * filters, etc and will be atomically updated whenever a reconfigure
>>>> occurs.
>>>>   */
>>>>  public class LoggerContext extends AbstractLifeCycle implements
>>>> org.apache.logging.log4j.spi.LoggerContext,
>>>> -        ConfigurationListener {
>>>> +        ShutdownCapable, ConfigurationListener {
>>>>
>>>>      /**
>>>>       * Property name of the property change event fired if the
>>>> configuration is changed.
>>>> @@ -278,6 +279,11 @@ public class LoggerContext extends
>>>> AbstractLifeCycle implements org.apache.loggi
>>>>      }
>>>>
>>>>      @Override
>>>> +    public void shutdown() {
>>>> +        stop();
>>>> +    }
>>>> +
>>>> +    @Override
>>>>      public void stop() {
>>>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...",
>>>> getName(), this);
>>>>          configLock.lock();
>>>>
>>>>
>>>
>>
>>

Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Remko Popma <re...@gmail.com>.
I actually like the simple shutdown() method, it should just be implemented
with getContext(false).

Remko

On Monday, 25 January 2016, Ralph Goers <ra...@dslextreme.com> wrote:

> Actually I would also like to remove shutdown(). It calls getContext()
> which most of the time is not what a user wants. I fear they may call that
> method and then be surprised when it doesn’t do anything.
>
> Ralph
>
> On Jan 24, 2016, at 3:43 PM, Remko Popma <remko.popma@gmail.com
> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com');>> wrote:
>
> Do we need all 6 methods?
>
> I like the first three:
> * shutdown()
> * shutdown(boolean)
> * shutdown(LoggerContext)
>
> I would argue that the next three are rare use cases. When needed these
> can be accomplished by calling
> LogManager.shutdown(LogManager.getContext(some params)).
>
> I would be in favor of removing these three convenience methods:
> * shutdown(String, boolean)
> * shutdown(String, ClassLoader, boolean)
> * shutdown(ClassLoader, boolean)
>
> Thoughts? -Remko
>
>
> On Mon, Jan 25, 2016 at 6:54 AM, Ralph Goers <ralph.goers@dslextreme.com
> <javascript:_e(%7B%7D,'cvml','ralph.goers@dslextreme.com');>> wrote:
>
>> Yes, Shutdownable is too weird. Closeable would imply there is a close
>> method, not a shutdown method.  I have my doubts about the
>> try-with-resources use case here.  Virtually all usages are probably going
>> to be to disable automatic shutdown and then the user placing the shutdown
>> call somewhere they can control, which probably will have nothing to do
>> with initialization of logging.
>>
>> Ralph
>>
>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <garydgregory@gmail.com
>> <javascript:_e(%7B%7D,'cvml','garydgregory@gmail.com');>> wrote:
>>
>> Resending, got a error from my phone...
>> ---------- Forwarded message ----------
>> From: "Gary Gregory" <garydgregory@gmail.com
>> <javascript:_e(%7B%7D,'cvml','garydgregory@gmail.com');>>
>> Date: Jan 24, 2016 1:41 PM
>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods
>> to LogManager
>> To: <dev@logging.apache.org
>> <javascript:_e(%7B%7D,'cvml','dev@logging.apache.org');>>
>> Cc:
>>
>> Hi all,
>>
>> Any reason not use the usual -able postfix instead of ShutdownCapable:
>> Shutdownable sounds too weird? What about reusing plain old Closeable? That
>> means you could use the context in a try-with-resources block, a bonus.
>>
>> Gary
>> On Jan 24, 2016 10:18 AM, <rgoers@apache.org
>> <javascript:_e(%7B%7D,'cvml','rgoers@apache.org');>> wrote:
>>
>>> Repository: logging-log4j2
>>> Updated Branches:
>>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>>>
>>>
>>> LOG4J2-124 - Add shutdown methods to LogManager
>>>
>>>
>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>> Commit:
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7
>>> Tree:
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7
>>> Diff:
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7
>>>
>>> Branch: refs/heads/master
>>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>>> Parents: 7d3aac4
>>> Author: Ralph Goers <rgoers@nextiva.com
>>> <javascript:_e(%7B%7D,'cvml','rgoers@nextiva.com');>>
>>> Authored: Sun Jan 24 11:18:41 2016 -0700
>>> Committer: Ralph Goers <rgoers@nextiva.com
>>> <javascript:_e(%7B%7D,'cvml','rgoers@nextiva.com');>>
>>> Committed: Sun Jan 24 11:18:41 2016 -0700
>>>
>>> ----------------------------------------------------------------------
>>>  .../org/apache/logging/log4j/LogManager.java    | 62
>>> ++++++++++++++++++++
>>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>>  4 files changed, 93 insertions(+), 1 deletion(-)
>>> ----------------------------------------------------------------------
>>>
>>>
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> ----------------------------------------------------------------------
>>> diff --git
>>> a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> index f10e5a8..64c6ee5 100644
>>> --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> @@ -27,6 +27,7 @@ import
>>> org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>>  import org.apache.logging.log4j.spi.LoggerContext;
>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>  import org.apache.logging.log4j.spi.Provider;
>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>  import org.apache.logging.log4j.status.StatusLogger;
>>>  import org.apache.logging.log4j.util.LoaderUtil;
>>>  import org.apache.logging.log4j.util.PropertiesUtil;
>>> @@ -285,6 +286,67 @@ public class LogManager {
>>>      }
>>>
>>>      /**
>>> +     * Shutdown using the default LoggerContext.
>>> +     * @since 2.6
>>> +     */
>>> +    public static void shutdown() {
>>> +        shutdown(getContext());
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param currentContext if true the LoggerContext for the caller
>>> of this method will be used.
>>> +     * @since 2.6
>>> +     */
>>> +    public static void shutdown(boolean currentContext) {
>>> +        shutdown(getContext(currentContext));
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param loader The ClassLoader for the context. If null the
>>> context will attempt to determine the appropriate
>>> +     *            ClassLoader.
>>> +     * @param currentContext if false the LoggerContext appropriate for
>>> the caller of this method will be used.
>>> +     * @since 2.6
>>> +     */
>>> +    public static void shutdown(final ClassLoader loader, final boolean
>>> currentContext) {
>>> +        shutdown(getContext(loader, currentContext));
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param context the LoggerContext.
>>> +     * @since 2.6
>>> +     */
>>> +    public static void shutdown(LoggerContext context) {
>>> +        if (context != null && context instanceof ShutdownCapable) {
>>> +            ((ShutdownCapable) context).shutdown();
>>> +        }
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param fqcn The fully qualified class name of the Class that
>>> this method is a member of.
>>> +     * @param currentContext if false the LoggerContext appropriate for
>>> the caller of this method will be used.
>>> +     * @since 2.6
>>> +     */
>>> +    protected static void shutdown(final String fqcn, final boolean
>>> currentContext) {
>>> +        shutdown(getContext(fqcn, currentContext));
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param fqcn The fully qualified class name of the Class that
>>> this method is a member of.
>>> +     * @param loader The ClassLoader for the context. If null the
>>> context will attempt to determine the appropriate
>>> +     *            ClassLoader.
>>> +     * @param currentContext if false the LoggerContext appropriate for
>>> the caller of this method will be used.
>>> +     * @since 2.6
>>> +     */
>>> +    protected static void shutdown(final String fqcn, final ClassLoader
>>> loader, final boolean currentContext) {
>>> +        shutdown(getContext(fqcn, loader, currentContext));
>>> +    }
>>> +
>>> +    /**
>>>       * Returns the current LoggerContextFactory.
>>>       *
>>>       * @return The LoggerContextFactory.
>>>
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>> ----------------------------------------------------------------------
>>> diff --git
>>> a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>> new file mode 100644
>>> index 0000000..a46ef60
>>> --- /dev/null
>>> +++
>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>> @@ -0,0 +1,17 @@
>>> +/*
>>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>>> + * All rights reserved.
>>> + */
>>> +package org.apache.logging.log4j.spi;
>>> +
>>> +/**
>>> + * Interface to be implemented by LoggerContext's that provide a
>>> shutdown method.
>>> + * @since 2.6
>>> + */
>>> +public interface ShutdownCapable {
>>> +
>>> +    /**
>>> +     * Requests that the logging implementation shut down.
>>> +     */
>>> +    void shutdown();
>>> +}
>>>
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> ----------------------------------------------------------------------
>>> diff --git
>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> index 48f0eea..596a9f2 100644
>>> ---
>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> +++
>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> @@ -17,6 +17,7 @@
>>>  package org.apache.logging.log4j;
>>>
>>>  import org.apache.logging.log4j.message.ParameterizedMessageFactory;
>>> +import org.apache.logging.log4j.spi.LoggerContext;
>>>  import org.junit.Test;
>>>
>>>  import static org.junit.Assert.*;
>>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>>          assertNotNull("No Logger returned", logger);
>>>          assertTrue("Incorrect Logger name: " +
>>> logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>>      }
>>> +
>>> +    @Test
>>> +    public void testShutdown() {
>>> +        LoggerContext loggerContext = LogManager.getContext(false);
>>> +        LogManager.shutdown(loggerContext);
>>> +    }
>>>  }
>>>
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> ----------------------------------------------------------------------
>>> diff --git
>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> index 42efbb5..fcdfc16 100644
>>> ---
>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> +++
>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> @@ -45,6 +45,7 @@ import org.apache.logging.log4j.message.MessageFactory;
>>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>
>>>  import static
>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>
>>> @@ -54,7 +55,7 @@ import static
>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>   * filters, etc and will be atomically updated whenever a reconfigure
>>> occurs.
>>>   */
>>>  public class LoggerContext extends AbstractLifeCycle implements
>>> org.apache.logging.log4j.spi.LoggerContext,
>>> -        ConfigurationListener {
>>> +        ShutdownCapable, ConfigurationListener {
>>>
>>>      /**
>>>       * Property name of the property change event fired if the
>>> configuration is changed.
>>> @@ -278,6 +279,11 @@ public class LoggerContext extends
>>> AbstractLifeCycle implements org.apache.loggi
>>>      }
>>>
>>>      @Override
>>> +    public void shutdown() {
>>> +        stop();
>>> +    }
>>> +
>>> +    @Override
>>>      public void stop() {
>>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...",
>>> getName(), this);
>>>          configLock.lock();
>>>
>>>
>>
>
>

Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Ralph Goers <ra...@dslextreme.com>.
Actually I would also like to remove shutdown(). It calls getContext() which most of the time is not what a user wants. I fear they may call that method and then be surprised when it doesn’t do anything.

Ralph

> On Jan 24, 2016, at 3:43 PM, Remko Popma <re...@gmail.com> wrote:
> 
> Do we need all 6 methods?
> 
> I like the first three:
> * shutdown()
> * shutdown(boolean)
> * shutdown(LoggerContext)
> 
> I would argue that the next three are rare use cases. When needed these can be accomplished by calling LogManager.shutdown(LogManager.getContext(some params)).
> 
> I would be in favor of removing these three convenience methods:
> * shutdown(String, boolean)
> * shutdown(String, ClassLoader, boolean)
> * shutdown(ClassLoader, boolean)
> 
> Thoughts? -Remko
> 
> 
> On Mon, Jan 25, 2016 at 6:54 AM, Ralph Goers <ralph.goers@dslextreme.com <ma...@dslextreme.com>> wrote:
> Yes, Shutdownable is too weird. Closeable would imply there is a close method, not a shutdown method.  I have my doubts about the try-with-resources use case here.  Virtually all usages are probably going to be to disable automatic shutdown and then the user placing the shutdown call somewhere they can control, which probably will have nothing to do with initialization of logging. 
> 
> Ralph
> 
>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <garydgregory@gmail.com <ma...@gmail.com>> wrote:
>> 
>> Resending, got a error from my phone...
>> 
>> ---------- Forwarded message ----------
>> From: "Gary Gregory" <garydgregory@gmail.com <ma...@gmail.com>>
>> Date: Jan 24, 2016 1:41 PM
>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager
>> To: <dev@logging.apache.org <ma...@logging.apache.org>>
>> Cc: 
>> 
>> Hi all,
>> 
>> Any reason not use the usual -able postfix instead of ShutdownCapable: Shutdownable sounds too weird? What about reusing plain old Closeable? That means you could use the context in a try-with-resources block, a bonus.
>> 
>> Gary
>> 
>> On Jan 24, 2016 10:18 AM, <rgoers@apache.org <ma...@apache.org>> wrote:
>> Repository: logging-log4j2
>> Updated Branches:
>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>> 
>> 
>> LOG4J2-124 - Add shutdown methods to LogManager
>> 
>> 
>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo <http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo>
>> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7>
>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7>
>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7>
>> 
>> Branch: refs/heads/master
>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>> Parents: 7d3aac4
>> Author: Ralph Goers <rgoers@nextiva.com <ma...@nextiva.com>>
>> Authored: Sun Jan 24 11:18:41 2016 -0700
>> Committer: Ralph Goers <rgoers@nextiva.com <ma...@nextiva.com>>
>> Committed: Sun Jan 24 11:18:41 2016 -0700
>> 
>> ----------------------------------------------------------------------
>>  .../org/apache/logging/log4j/LogManager.java    | 62 ++++++++++++++++++++
>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>  4 files changed, 93 insertions(+), 1 deletion(-)
>> ----------------------------------------------------------------------
>> 
>> 
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java>
>> ----------------------------------------------------------------------
>> diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>> index f10e5a8..64c6ee5 100644
>> --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>> @@ -27,6 +27,7 @@ import org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>  import org.apache.logging.log4j.spi.LoggerContext;
>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>  import org.apache.logging.log4j.spi.Provider;
>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>  import org.apache.logging.log4j.status.StatusLogger;
>>  import org.apache.logging.log4j.util.LoaderUtil;
>>  import org.apache.logging.log4j.util.PropertiesUtil;
>> @@ -285,6 +286,67 @@ public class LogManager {
>>      }
>> 
>>      /**
>> +     * Shutdown using the default LoggerContext.
>> +     * @since 2.6
>> +     */
>> +    public static void shutdown() {
>> +        shutdown(getContext());
>> +    }
>> +
>> +    /**
>> +     * Shutdown the logging system if the logging system supports it.
>> +     * @param currentContext if true the LoggerContext for the caller of this method will be used.
>> +     * @since 2.6
>> +     */
>> +    public static void shutdown(boolean currentContext) {
>> +        shutdown(getContext(currentContext));
>> +    }
>> +
>> +    /**
>> +     * Shutdown the logging system if the logging system supports it.
>> +     * @param loader The ClassLoader for the context. If null the context will attempt to determine the appropriate
>> +     *            ClassLoader.
>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>> +     * @since 2.6
>> +     */
>> +    public static void shutdown(final ClassLoader loader, final boolean currentContext) {
>> +        shutdown(getContext(loader, currentContext));
>> +    }
>> +
>> +    /**
>> +     * Shutdown the logging system if the logging system supports it.
>> +     * @param context the LoggerContext.
>> +     * @since 2.6
>> +     */
>> +    public static void shutdown(LoggerContext context) {
>> +        if (context != null && context instanceof ShutdownCapable) {
>> +            ((ShutdownCapable) context).shutdown();
>> +        }
>> +    }
>> +
>> +    /**
>> +     * Shutdown the logging system if the logging system supports it.
>> +     * @param fqcn The fully qualified class name of the Class that this method is a member of.
>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>> +     * @since 2.6
>> +     */
>> +    protected static void shutdown(final String fqcn, final boolean currentContext) {
>> +        shutdown(getContext(fqcn, currentContext));
>> +    }
>> +
>> +    /**
>> +     * Shutdown the logging system if the logging system supports it.
>> +     * @param fqcn The fully qualified class name of the Class that this method is a member of.
>> +     * @param loader The ClassLoader for the context. If null the context will attempt to determine the appropriate
>> +     *            ClassLoader.
>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>> +     * @since 2.6
>> +     */
>> +    protected static void shutdown(final String fqcn, final ClassLoader loader, final boolean currentContext) {
>> +        shutdown(getContext(fqcn, loader, currentContext));
>> +    }
>> +
>> +    /**
>>       * Returns the current LoggerContextFactory.
>>       *
>>       * @return The LoggerContextFactory.
>> 
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java>
>> ----------------------------------------------------------------------
>> diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>> new file mode 100644
>> index 0000000..a46ef60
>> --- /dev/null
>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>> @@ -0,0 +1,17 @@
>> +/*
>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>> + * All rights reserved.
>> + */
>> +package org.apache.logging.log4j.spi;
>> +
>> +/**
>> + * Interface to be implemented by LoggerContext's that provide a shutdown method.
>> + * @since 2.6
>> + */
>> +public interface ShutdownCapable {
>> +
>> +    /**
>> +     * Requests that the logging implementation shut down.
>> +     */
>> +    void shutdown();
>> +}
>> 
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java>
>> ----------------------------------------------------------------------
>> diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>> index 48f0eea..596a9f2 100644
>> --- a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>> +++ b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>> @@ -17,6 +17,7 @@
>>  package org.apache.logging.log4j;
>> 
>>  import org.apache.logging.log4j.message.ParameterizedMessageFactory;
>> +import org.apache.logging.log4j.spi.LoggerContext;
>>  import org.junit.Test;
>> 
>>  import static org.junit.Assert.*;
>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>          assertNotNull("No Logger returned", logger);
>>          assertTrue("Incorrect Logger name: " + logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>      }
>> +
>> +    @Test
>> +    public void testShutdown() {
>> +        LoggerContext loggerContext = LogManager.getContext(false);
>> +        LogManager.shutdown(loggerContext);
>> +    }
>>  }
>> 
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java>
>> ----------------------------------------------------------------------
>> diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>> index 42efbb5..fcdfc16 100644
>> --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>> +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>> @@ -45,6 +45,7 @@ import org.apache.logging.log4j.message.MessageFactory;
>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>> 
>>  import static org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>> 
>> @@ -54,7 +55,7 @@ import static org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>   * filters, etc and will be atomically updated whenever a reconfigure occurs.
>>   */
>>  public class LoggerContext extends AbstractLifeCycle implements org.apache.logging.log4j.spi.LoggerContext,
>> -        ConfigurationListener {
>> +        ShutdownCapable, ConfigurationListener {
>> 
>>      /**
>>       * Property name of the property change event fired if the configuration is changed.
>> @@ -278,6 +279,11 @@ public class LoggerContext extends AbstractLifeCycle implements org.apache.loggi
>>      }
>> 
>>      @Override
>> +    public void shutdown() {
>> +        stop();
>> +    }
>> +
>> +    @Override
>>      public void stop() {
>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...", getName(), this);
>>          configLock.lock();
>> 
> 
> 


Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Ralph Goers <ra...@dslextreme.com>.
I only added all the methods to match the getContext() methods. If you guys want to eliminate a few of them that is fine by me.

The protected methods match the protected getContext() methods.

I only implemented a single unit test because they are all essentially the same. All you end up testing is getContext() again.  

Ralph

> On Jan 24, 2016, at 4:33 PM, Gary Gregory <ga...@gmail.com> wrote:
> 
> On Sun, Jan 24, 2016 at 2:43 PM, Remko Popma <remko.popma@gmail.com <ma...@gmail.com>> wrote:
> Do we need all 6 methods?
> 
> I like the first three:
> * shutdown()
> * shutdown(boolean)
> * shutdown(LoggerContext)
> 
> I would argue that the next three are rare use cases. When needed these can be accomplished by calling LogManager.shutdown(LogManager.getContext(some params)).
> 
> I would be in favor of removing these three convenience methods:
> * shutdown(String, boolean)
> * shutdown(String, ClassLoader, boolean)
> * shutdown(ClassLoader, boolean)
> 
> Thoughts? -Remko
> 
> That does not see bad to me. We have lots of getLogger() and getContext() methods. 
> 
> I wonder why these are protected through:
> 
> org.apache.logging.log4j.LogManager.shutdown(String, boolean)
> org.apache.logging.log4j.LogManager.shutdown(String, ClassLoader, boolean) 
> 
> Also, these along with:
> 
> org.apache.logging.log4j.LogManager.shutdown()
> org.apache.logging.log4j.LogManager.shutdown(boolean)
> org.apache.logging.log4j.LogManager.shutdown(ClassLoader, boolean)
> 
> have no senders, so no unit tests?
> 
> Gary
> 
> 
> 
> 
> On Mon, Jan 25, 2016 at 6:54 AM, Ralph Goers <ralph.goers@dslextreme.com <ma...@dslextreme.com>> wrote:
> Yes, Shutdownable is too weird. Closeable would imply there is a close method, not a shutdown method.  I have my doubts about the try-with-resources use case here.  Virtually all usages are probably going to be to disable automatic shutdown and then the user placing the shutdown call somewhere they can control, which probably will have nothing to do with initialization of logging. 
> 
> Ralph
> 
>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <garydgregory@gmail.com <ma...@gmail.com>> wrote:
>> 
>> Resending, got a error from my phone...
>> 
>> ---------- Forwarded message ----------
>> From: "Gary Gregory" <garydgregory@gmail.com <ma...@gmail.com>>
>> Date: Jan 24, 2016 1:41 PM
>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager
>> To: <dev@logging.apache.org <ma...@logging.apache.org>>
>> Cc: 
>> 
>> Hi all,
>> 
>> Any reason not use the usual -able postfix instead of ShutdownCapable: Shutdownable sounds too weird? What about reusing plain old Closeable? That means you could use the context in a try-with-resources block, a bonus.
>> 
>> Gary 
>> 
>> On Jan 24, 2016 10:18 AM, <rgoers@apache.org <ma...@apache.org>> wrote:
>> Repository: logging-log4j2
>> Updated Branches:
>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>> 
>> 
>> LOG4J2-124 - Add shutdown methods to LogManager
>> 
>> 
>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo <http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo>
>> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7>
>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7>
>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7>
>> 
>> Branch: refs/heads/master
>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>> Parents: 7d3aac4
>> Author: Ralph Goers <rgoers@nextiva.com <ma...@nextiva.com>>
>> Authored: Sun Jan 24 11:18:41 2016 -0700
>> Committer: Ralph Goers <rgoers@nextiva.com <ma...@nextiva.com>>
>> Committed: Sun Jan 24 11:18:41 2016 -0700
>> 
>> ----------------------------------------------------------------------
>>  .../org/apache/logging/log4j/LogManager.java    | 62 ++++++++++++++++++++
>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>  4 files changed, 93 insertions(+), 1 deletion(-)
>> ----------------------------------------------------------------------
>> 
>> 
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java>
>> ----------------------------------------------------------------------
>> diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>> index f10e5a8..64c6ee5 100644
>> --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>> @@ -27,6 +27,7 @@ import org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>  import org.apache.logging.log4j.spi.LoggerContext;
>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>  import org.apache.logging.log4j.spi.Provider;
>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>  import org.apache.logging.log4j.status.StatusLogger;
>>  import org.apache.logging.log4j.util.LoaderUtil;
>>  import org.apache.logging.log4j.util.PropertiesUtil;
>> @@ -285,6 +286,67 @@ public class LogManager {
>>      }
>> 
>>      /**
>> +     * Shutdown using the default LoggerContext.
>> +     * @since 2.6
>> +     */
>> +    public static void shutdown() {
>> +        shutdown(getContext());
>> +    }
>> +
>> +    /**
>> +     * Shutdown the logging system if the logging system supports it.
>> +     * @param currentContext if true the LoggerContext for the caller of this method will be used.
>> +     * @since 2.6
>> +     */
>> +    public static void shutdown(boolean currentContext) {
>> +        shutdown(getContext(currentContext));
>> +    }
>> +
>> +    /**
>> +     * Shutdown the logging system if the logging system supports it.
>> +     * @param loader The ClassLoader for the context. If null the context will attempt to determine the appropriate
>> +     *            ClassLoader.
>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>> +     * @since 2.6
>> +     */
>> +    public static void shutdown(final ClassLoader loader, final boolean currentContext) {
>> +        shutdown(getContext(loader, currentContext));
>> +    }
>> +
>> +    /**
>> +     * Shutdown the logging system if the logging system supports it.
>> +     * @param context the LoggerContext.
>> +     * @since 2.6
>> +     */
>> +    public static void shutdown(LoggerContext context) {
>> +        if (context != null && context instanceof ShutdownCapable) {
>> +            ((ShutdownCapable) context).shutdown();
>> +        }
>> +    }
>> +
>> +    /**
>> +     * Shutdown the logging system if the logging system supports it.
>> +     * @param fqcn The fully qualified class name of the Class that this method is a member of.
>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>> +     * @since 2.6
>> +     */
>> +    protected static void shutdown(final String fqcn, final boolean currentContext) {
>> +        shutdown(getContext(fqcn, currentContext));
>> +    }
>> +
>> +    /**
>> +     * Shutdown the logging system if the logging system supports it.
>> +     * @param fqcn The fully qualified class name of the Class that this method is a member of.
>> +     * @param loader The ClassLoader for the context. If null the context will attempt to determine the appropriate
>> +     *            ClassLoader.
>> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
>> +     * @since 2.6
>> +     */
>> +    protected static void shutdown(final String fqcn, final ClassLoader loader, final boolean currentContext) {
>> +        shutdown(getContext(fqcn, loader, currentContext));
>> +    }
>> +
>> +    /**
>>       * Returns the current LoggerContextFactory.
>>       *
>>       * @return The LoggerContextFactory.
>> 
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java>
>> ----------------------------------------------------------------------
>> diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>> new file mode 100644
>> index 0000000..a46ef60
>> --- /dev/null
>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>> @@ -0,0 +1,17 @@
>> +/*
>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>> + * All rights reserved.
>> + */
>> +package org.apache.logging.log4j.spi;
>> +
>> +/**
>> + * Interface to be implemented by LoggerContext's that provide a shutdown method.
>> + * @since 2.6
>> + */
>> +public interface ShutdownCapable {
>> +
>> +    /**
>> +     * Requests that the logging implementation shut down.
>> +     */
>> +    void shutdown();
>> +}
>> 
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java>
>> ----------------------------------------------------------------------
>> diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>> index 48f0eea..596a9f2 100644
>> --- a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>> +++ b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>> @@ -17,6 +17,7 @@
>>  package org.apache.logging.log4j;
>> 
>>  import org.apache.logging.log4j.message.ParameterizedMessageFactory;
>> +import org.apache.logging.log4j.spi.LoggerContext;
>>  import org.junit.Test;
>> 
>>  import static org.junit.Assert.*;
>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>          assertNotNull("No Logger returned", logger);
>>          assertTrue("Incorrect Logger name: " + logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>      }
>> +
>> +    @Test
>> +    public void testShutdown() {
>> +        LoggerContext loggerContext = LogManager.getContext(false);
>> +        LogManager.shutdown(loggerContext);
>> +    }
>>  }
>> 
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java>
>> ----------------------------------------------------------------------
>> diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>> index 42efbb5..fcdfc16 100644
>> --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>> +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>> @@ -45,6 +45,7 @@ import org.apache.logging.log4j.message.MessageFactory;
>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>> 
>>  import static org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>> 
>> @@ -54,7 +55,7 @@ import static org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>   * filters, etc and will be atomically updated whenever a reconfigure occurs.
>>   */
>>  public class LoggerContext extends AbstractLifeCycle implements org.apache.logging.log4j.spi.LoggerContext,
>> -        ConfigurationListener {
>> +        ShutdownCapable, ConfigurationListener {
>> 
>>      /**
>>       * Property name of the property change event fired if the configuration is changed.
>> @@ -278,6 +279,11 @@ public class LoggerContext extends AbstractLifeCycle implements org.apache.loggi
>>      }
>> 
>>      @Override
>> +    public void shutdown() {
>> +        stop();
>> +    }
>> +
>> +    @Override
>>      public void stop() {
>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...", getName(), this);
>>          configLock.lock();
>> 
> 
> 
> 
> 
> 
> -- 
> E-Mail: garydgregory@gmail.com <ma...@gmail.com> | ggregory@apache.org  <ma...@apache.org>
> Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> 
> Home: http://garygregory.com/ <http://garygregory.com/>
> Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>

Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Gary Gregory <ga...@gmail.com>.
On Sun, Jan 24, 2016 at 2:43 PM, Remko Popma <re...@gmail.com> wrote:

> Do we need all 6 methods?
>
> I like the first three:
> * shutdown()
> * shutdown(boolean)
> * shutdown(LoggerContext)
>
> I would argue that the next three are rare use cases. When needed these
> can be accomplished by calling
> LogManager.shutdown(LogManager.getContext(some params)).
>
> I would be in favor of removing these three convenience methods:
> * shutdown(String, boolean)
> * shutdown(String, ClassLoader, boolean)
> * shutdown(ClassLoader, boolean)
>
> Thoughts? -Remko
>

That does not see bad to me. We have lots of getLogger() and getContext()
methods.

I wonder why these are protected through:

org.apache.logging.log4j.LogManager.shutdown(String, boolean)
org.apache.logging.log4j.LogManager.shutdown(String, ClassLoader, boolean)

Also, these along with:

org.apache.logging.log4j.LogManager.shutdown()
org.apache.logging.log4j.LogManager.shutdown(boolean)
org.apache.logging.log4j.LogManager.shutdown(ClassLoader, boolean)

have no senders, so no unit tests?

Gary



>
> On Mon, Jan 25, 2016 at 6:54 AM, Ralph Goers <ra...@dslextreme.com>
> wrote:
>
>> Yes, Shutdownable is too weird. Closeable would imply there is a close
>> method, not a shutdown method.  I have my doubts about the
>> try-with-resources use case here.  Virtually all usages are probably going
>> to be to disable automatic shutdown and then the user placing the shutdown
>> call somewhere they can control, which probably will have nothing to do
>> with initialization of logging.
>>
>> Ralph
>>
>> On Jan 24, 2016, at 2:43 PM, Gary Gregory <ga...@gmail.com> wrote:
>>
>> Resending, got a error from my phone...
>> ---------- Forwarded message ----------
>> From: "Gary Gregory" <ga...@gmail.com>
>> Date: Jan 24, 2016 1:41 PM
>> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods
>> to LogManager
>> To: <de...@logging.apache.org>
>> Cc:
>>
>> Hi all,
>>
>> Any reason not use the usual -able postfix instead of ShutdownCapable:
>> Shutdownable sounds too weird? What about reusing plain old Closeable? That
>> means you could use the context in a try-with-resources block, a bonus.
>>
>> Gary
>> On Jan 24, 2016 10:18 AM, <rg...@apache.org> wrote:
>>
>>> Repository: logging-log4j2
>>> Updated Branches:
>>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>>>
>>>
>>> LOG4J2-124 - Add shutdown methods to LogManager
>>>
>>>
>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>> Commit:
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7
>>> Tree:
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7
>>> Diff:
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7
>>>
>>> Branch: refs/heads/master
>>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>>> Parents: 7d3aac4
>>> Author: Ralph Goers <rg...@nextiva.com>
>>> Authored: Sun Jan 24 11:18:41 2016 -0700
>>> Committer: Ralph Goers <rg...@nextiva.com>
>>> Committed: Sun Jan 24 11:18:41 2016 -0700
>>>
>>> ----------------------------------------------------------------------
>>>  .../org/apache/logging/log4j/LogManager.java    | 62
>>> ++++++++++++++++++++
>>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>>  4 files changed, 93 insertions(+), 1 deletion(-)
>>> ----------------------------------------------------------------------
>>>
>>>
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> ----------------------------------------------------------------------
>>> diff --git
>>> a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> index f10e5a8..64c6ee5 100644
>>> --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>>> @@ -27,6 +27,7 @@ import
>>> org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>>  import org.apache.logging.log4j.spi.LoggerContext;
>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>  import org.apache.logging.log4j.spi.Provider;
>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>  import org.apache.logging.log4j.status.StatusLogger;
>>>  import org.apache.logging.log4j.util.LoaderUtil;
>>>  import org.apache.logging.log4j.util.PropertiesUtil;
>>> @@ -285,6 +286,67 @@ public class LogManager {
>>>      }
>>>
>>>      /**
>>> +     * Shutdown using the default LoggerContext.
>>> +     * @since 2.6
>>> +     */
>>> +    public static void shutdown() {
>>> +        shutdown(getContext());
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param currentContext if true the LoggerContext for the caller
>>> of this method will be used.
>>> +     * @since 2.6
>>> +     */
>>> +    public static void shutdown(boolean currentContext) {
>>> +        shutdown(getContext(currentContext));
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param loader The ClassLoader for the context. If null the
>>> context will attempt to determine the appropriate
>>> +     *            ClassLoader.
>>> +     * @param currentContext if false the LoggerContext appropriate for
>>> the caller of this method will be used.
>>> +     * @since 2.6
>>> +     */
>>> +    public static void shutdown(final ClassLoader loader, final boolean
>>> currentContext) {
>>> +        shutdown(getContext(loader, currentContext));
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param context the LoggerContext.
>>> +     * @since 2.6
>>> +     */
>>> +    public static void shutdown(LoggerContext context) {
>>> +        if (context != null && context instanceof ShutdownCapable) {
>>> +            ((ShutdownCapable) context).shutdown();
>>> +        }
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param fqcn The fully qualified class name of the Class that
>>> this method is a member of.
>>> +     * @param currentContext if false the LoggerContext appropriate for
>>> the caller of this method will be used.
>>> +     * @since 2.6
>>> +     */
>>> +    protected static void shutdown(final String fqcn, final boolean
>>> currentContext) {
>>> +        shutdown(getContext(fqcn, currentContext));
>>> +    }
>>> +
>>> +    /**
>>> +     * Shutdown the logging system if the logging system supports it.
>>> +     * @param fqcn The fully qualified class name of the Class that
>>> this method is a member of.
>>> +     * @param loader The ClassLoader for the context. If null the
>>> context will attempt to determine the appropriate
>>> +     *            ClassLoader.
>>> +     * @param currentContext if false the LoggerContext appropriate for
>>> the caller of this method will be used.
>>> +     * @since 2.6
>>> +     */
>>> +    protected static void shutdown(final String fqcn, final ClassLoader
>>> loader, final boolean currentContext) {
>>> +        shutdown(getContext(fqcn, loader, currentContext));
>>> +    }
>>> +
>>> +    /**
>>>       * Returns the current LoggerContextFactory.
>>>       *
>>>       * @return The LoggerContextFactory.
>>>
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>> ----------------------------------------------------------------------
>>> diff --git
>>> a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>> new file mode 100644
>>> index 0000000..a46ef60
>>> --- /dev/null
>>> +++
>>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>>> @@ -0,0 +1,17 @@
>>> +/*
>>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>>> + * All rights reserved.
>>> + */
>>> +package org.apache.logging.log4j.spi;
>>> +
>>> +/**
>>> + * Interface to be implemented by LoggerContext's that provide a
>>> shutdown method.
>>> + * @since 2.6
>>> + */
>>> +public interface ShutdownCapable {
>>> +
>>> +    /**
>>> +     * Requests that the logging implementation shut down.
>>> +     */
>>> +    void shutdown();
>>> +}
>>>
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> ----------------------------------------------------------------------
>>> diff --git
>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> index 48f0eea..596a9f2 100644
>>> ---
>>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> +++
>>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>>> @@ -17,6 +17,7 @@
>>>  package org.apache.logging.log4j;
>>>
>>>  import org.apache.logging.log4j.message.ParameterizedMessageFactory;
>>> +import org.apache.logging.log4j.spi.LoggerContext;
>>>  import org.junit.Test;
>>>
>>>  import static org.junit.Assert.*;
>>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>>          assertNotNull("No Logger returned", logger);
>>>          assertTrue("Incorrect Logger name: " +
>>> logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>>      }
>>> +
>>> +    @Test
>>> +    public void testShutdown() {
>>> +        LoggerContext loggerContext = LogManager.getContext(false);
>>> +        LogManager.shutdown(loggerContext);
>>> +    }
>>>  }
>>>
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> ----------------------------------------------------------------------
>>> diff --git
>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> index 42efbb5..fcdfc16 100644
>>> ---
>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> +++
>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>>> @@ -45,6 +45,7 @@ import org.apache.logging.log4j.message.MessageFactory;
>>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>>
>>>  import static
>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>
>>> @@ -54,7 +55,7 @@ import static
>>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>>   * filters, etc and will be atomically updated whenever a reconfigure
>>> occurs.
>>>   */
>>>  public class LoggerContext extends AbstractLifeCycle implements
>>> org.apache.logging.log4j.spi.LoggerContext,
>>> -        ConfigurationListener {
>>> +        ShutdownCapable, ConfigurationListener {
>>>
>>>      /**
>>>       * Property name of the property change event fired if the
>>> configuration is changed.
>>> @@ -278,6 +279,11 @@ public class LoggerContext extends
>>> AbstractLifeCycle implements org.apache.loggi
>>>      }
>>>
>>>      @Override
>>> +    public void shutdown() {
>>> +        stop();
>>> +    }
>>> +
>>> +    @Override
>>>      public void stop() {
>>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...",
>>> getName(), this);
>>>          configLock.lock();
>>>
>>>
>>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Remko Popma <re...@gmail.com>.
Do we need all 6 methods?

I like the first three:
* shutdown()
* shutdown(boolean)
* shutdown(LoggerContext)

I would argue that the next three are rare use cases. When needed these can
be accomplished by calling LogManager.shutdown(LogManager.getContext(some
params)).

I would be in favor of removing these three convenience methods:
* shutdown(String, boolean)
* shutdown(String, ClassLoader, boolean)
* shutdown(ClassLoader, boolean)

Thoughts? -Remko


On Mon, Jan 25, 2016 at 6:54 AM, Ralph Goers <ra...@dslextreme.com>
wrote:

> Yes, Shutdownable is too weird. Closeable would imply there is a close
> method, not a shutdown method.  I have my doubts about the
> try-with-resources use case here.  Virtually all usages are probably going
> to be to disable automatic shutdown and then the user placing the shutdown
> call somewhere they can control, which probably will have nothing to do
> with initialization of logging.
>
> Ralph
>
> On Jan 24, 2016, at 2:43 PM, Gary Gregory <ga...@gmail.com> wrote:
>
> Resending, got a error from my phone...
> ---------- Forwarded message ----------
> From: "Gary Gregory" <ga...@gmail.com>
> Date: Jan 24, 2016 1:41 PM
> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods
> to LogManager
> To: <de...@logging.apache.org>
> Cc:
>
> Hi all,
>
> Any reason not use the usual -able postfix instead of ShutdownCapable:
> Shutdownable sounds too weird? What about reusing plain old Closeable? That
> means you could use the context in a try-with-resources block, a bonus.
>
> Gary
> On Jan 24, 2016 10:18 AM, <rg...@apache.org> wrote:
>
>> Repository: logging-log4j2
>> Updated Branches:
>>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
>>
>>
>> LOG4J2-124 - Add shutdown methods to LogManager
>>
>>
>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>> Commit:
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7
>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7
>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7
>>
>> Branch: refs/heads/master
>> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
>> Parents: 7d3aac4
>> Author: Ralph Goers <rg...@nextiva.com>
>> Authored: Sun Jan 24 11:18:41 2016 -0700
>> Committer: Ralph Goers <rg...@nextiva.com>
>> Committed: Sun Jan 24 11:18:41 2016 -0700
>>
>> ----------------------------------------------------------------------
>>  .../org/apache/logging/log4j/LogManager.java    | 62 ++++++++++++++++++++
>>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>>  4 files changed, 93 insertions(+), 1 deletion(-)
>> ----------------------------------------------------------------------
>>
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>> b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>> index f10e5a8..64c6ee5 100644
>> --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
>> @@ -27,6 +27,7 @@ import
>> org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>>  import org.apache.logging.log4j.spi.LoggerContext;
>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>  import org.apache.logging.log4j.spi.Provider;
>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>  import org.apache.logging.log4j.status.StatusLogger;
>>  import org.apache.logging.log4j.util.LoaderUtil;
>>  import org.apache.logging.log4j.util.PropertiesUtil;
>> @@ -285,6 +286,67 @@ public class LogManager {
>>      }
>>
>>      /**
>> +     * Shutdown using the default LoggerContext.
>> +     * @since 2.6
>> +     */
>> +    public static void shutdown() {
>> +        shutdown(getContext());
>> +    }
>> +
>> +    /**
>> +     * Shutdown the logging system if the logging system supports it.
>> +     * @param currentContext if true the LoggerContext for the caller of
>> this method will be used.
>> +     * @since 2.6
>> +     */
>> +    public static void shutdown(boolean currentContext) {
>> +        shutdown(getContext(currentContext));
>> +    }
>> +
>> +    /**
>> +     * Shutdown the logging system if the logging system supports it.
>> +     * @param loader The ClassLoader for the context. If null the
>> context will attempt to determine the appropriate
>> +     *            ClassLoader.
>> +     * @param currentContext if false the LoggerContext appropriate for
>> the caller of this method will be used.
>> +     * @since 2.6
>> +     */
>> +    public static void shutdown(final ClassLoader loader, final boolean
>> currentContext) {
>> +        shutdown(getContext(loader, currentContext));
>> +    }
>> +
>> +    /**
>> +     * Shutdown the logging system if the logging system supports it.
>> +     * @param context the LoggerContext.
>> +     * @since 2.6
>> +     */
>> +    public static void shutdown(LoggerContext context) {
>> +        if (context != null && context instanceof ShutdownCapable) {
>> +            ((ShutdownCapable) context).shutdown();
>> +        }
>> +    }
>> +
>> +    /**
>> +     * Shutdown the logging system if the logging system supports it.
>> +     * @param fqcn The fully qualified class name of the Class that this
>> method is a member of.
>> +     * @param currentContext if false the LoggerContext appropriate for
>> the caller of this method will be used.
>> +     * @since 2.6
>> +     */
>> +    protected static void shutdown(final String fqcn, final boolean
>> currentContext) {
>> +        shutdown(getContext(fqcn, currentContext));
>> +    }
>> +
>> +    /**
>> +     * Shutdown the logging system if the logging system supports it.
>> +     * @param fqcn The fully qualified class name of the Class that this
>> method is a member of.
>> +     * @param loader The ClassLoader for the context. If null the
>> context will attempt to determine the appropriate
>> +     *            ClassLoader.
>> +     * @param currentContext if false the LoggerContext appropriate for
>> the caller of this method will be used.
>> +     * @since 2.6
>> +     */
>> +    protected static void shutdown(final String fqcn, final ClassLoader
>> loader, final boolean currentContext) {
>> +        shutdown(getContext(fqcn, loader, currentContext));
>> +    }
>> +
>> +    /**
>>       * Returns the current LoggerContextFactory.
>>       *
>>       * @return The LoggerContextFactory.
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>> new file mode 100644
>> index 0000000..a46ef60
>> --- /dev/null
>> +++
>> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
>> @@ -0,0 +1,17 @@
>> +/*
>> + * Copyright (c) 2016 Nextiva, Inc. to Present.
>> + * All rights reserved.
>> + */
>> +package org.apache.logging.log4j.spi;
>> +
>> +/**
>> + * Interface to be implemented by LoggerContext's that provide a
>> shutdown method.
>> + * @since 2.6
>> + */
>> +public interface ShutdownCapable {
>> +
>> +    /**
>> +     * Requests that the logging implementation shut down.
>> +     */
>> +    void shutdown();
>> +}
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>> b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>> index 48f0eea..596a9f2 100644
>> --- a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>> +++ b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
>> @@ -17,6 +17,7 @@
>>  package org.apache.logging.log4j;
>>
>>  import org.apache.logging.log4j.message.ParameterizedMessageFactory;
>> +import org.apache.logging.log4j.spi.LoggerContext;
>>  import org.junit.Test;
>>
>>  import static org.junit.Assert.*;
>> @@ -53,4 +54,10 @@ public class LogManagerTest {
>>          assertNotNull("No Logger returned", logger);
>>          assertTrue("Incorrect Logger name: " +
>> logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>>      }
>> +
>> +    @Test
>> +    public void testShutdown() {
>> +        LoggerContext loggerContext = LogManager.getContext(false);
>> +        LogManager.shutdown(loggerContext);
>> +    }
>>  }
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>> index 42efbb5..fcdfc16 100644
>> ---
>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>> +++
>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
>> @@ -45,6 +45,7 @@ import org.apache.logging.log4j.message.MessageFactory;
>>  import org.apache.logging.log4j.spi.AbstractLogger;
>>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>>  import org.apache.logging.log4j.spi.LoggerContextKey;
>> +import org.apache.logging.log4j.spi.ShutdownCapable;
>>
>>  import static
>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>
>> @@ -54,7 +55,7 @@ import static
>> org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>>   * filters, etc and will be atomically updated whenever a reconfigure
>> occurs.
>>   */
>>  public class LoggerContext extends AbstractLifeCycle implements
>> org.apache.logging.log4j.spi.LoggerContext,
>> -        ConfigurationListener {
>> +        ShutdownCapable, ConfigurationListener {
>>
>>      /**
>>       * Property name of the property change event fired if the
>> configuration is changed.
>> @@ -278,6 +279,11 @@ public class LoggerContext extends AbstractLifeCycle
>> implements org.apache.loggi
>>      }
>>
>>      @Override
>> +    public void shutdown() {
>> +        stop();
>> +    }
>> +
>> +    @Override
>>      public void stop() {
>>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...",
>> getName(), this);
>>          configLock.lock();
>>
>>
>

Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager

Posted by Ralph Goers <ra...@dslextreme.com>.
Yes, Shutdownable is too weird. Closeable would imply there is a close method, not a shutdown method.  I have my doubts about the try-with-resources use case here.  Virtually all usages are probably going to be to disable automatic shutdown and then the user placing the shutdown call somewhere they can control, which probably will have nothing to do with initialization of logging. 

Ralph

> On Jan 24, 2016, at 2:43 PM, Gary Gregory <ga...@gmail.com> wrote:
> 
> Resending, got a error from my phone...
> 
> ---------- Forwarded message ----------
> From: "Gary Gregory" <garydgregory@gmail.com <ma...@gmail.com>>
> Date: Jan 24, 2016 1:41 PM
> Subject: Re: logging-log4j2 git commit: LOG4J2-124 - Add shutdown methods to LogManager
> To: <dev@logging.apache.org <ma...@logging.apache.org>>
> Cc: 
> 
> Hi all,
> 
> Any reason not use the usual -able postfix instead of ShutdownCapable: Shutdownable sounds too weird? What about reusing plain old Closeable? That means you could use the context in a try-with-resources block, a bonus.
> 
> Gary
> 
> On Jan 24, 2016 10:18 AM, <rgoers@apache.org <ma...@apache.org>> wrote:
> Repository: logging-log4j2
> Updated Branches:
>   refs/heads/master 7d3aac4b9 -> 2df3f0e72
> 
> 
> LOG4J2-124 - Add shutdown methods to LogManager
> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo <http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo>
> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2df3f0e7>
> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2df3f0e7>
> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2df3f0e7>
> 
> Branch: refs/heads/master
> Commit: 2df3f0e7262c90e3fe1700f053eebf18491650d9
> Parents: 7d3aac4
> Author: Ralph Goers <rgoers@nextiva.com <ma...@nextiva.com>>
> Authored: Sun Jan 24 11:18:41 2016 -0700
> Committer: Ralph Goers <rgoers@nextiva.com <ma...@nextiva.com>>
> Committed: Sun Jan 24 11:18:41 2016 -0700
> 
> ----------------------------------------------------------------------
>  .../org/apache/logging/log4j/LogManager.java    | 62 ++++++++++++++++++++
>  .../logging/log4j/spi/ShutdownCapable.java      | 17 ++++++
>  .../apache/logging/log4j/LogManagerTest.java    |  7 +++
>  .../logging/log4j/core/LoggerContext.java       |  8 ++-
>  4 files changed, 93 insertions(+), 1 deletion(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java>
> ----------------------------------------------------------------------
> diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
> index f10e5a8..64c6ee5 100644
> --- a/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/LogManager.java
> @@ -27,6 +27,7 @@ import org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
>  import org.apache.logging.log4j.spi.LoggerContext;
>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>  import org.apache.logging.log4j.spi.Provider;
> +import org.apache.logging.log4j.spi.ShutdownCapable;
>  import org.apache.logging.log4j.status.StatusLogger;
>  import org.apache.logging.log4j.util.LoaderUtil;
>  import org.apache.logging.log4j.util.PropertiesUtil;
> @@ -285,6 +286,67 @@ public class LogManager {
>      }
> 
>      /**
> +     * Shutdown using the default LoggerContext.
> +     * @since 2.6
> +     */
> +    public static void shutdown() {
> +        shutdown(getContext());
> +    }
> +
> +    /**
> +     * Shutdown the logging system if the logging system supports it.
> +     * @param currentContext if true the LoggerContext for the caller of this method will be used.
> +     * @since 2.6
> +     */
> +    public static void shutdown(boolean currentContext) {
> +        shutdown(getContext(currentContext));
> +    }
> +
> +    /**
> +     * Shutdown the logging system if the logging system supports it.
> +     * @param loader The ClassLoader for the context. If null the context will attempt to determine the appropriate
> +     *            ClassLoader.
> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
> +     * @since 2.6
> +     */
> +    public static void shutdown(final ClassLoader loader, final boolean currentContext) {
> +        shutdown(getContext(loader, currentContext));
> +    }
> +
> +    /**
> +     * Shutdown the logging system if the logging system supports it.
> +     * @param context the LoggerContext.
> +     * @since 2.6
> +     */
> +    public static void shutdown(LoggerContext context) {
> +        if (context != null && context instanceof ShutdownCapable) {
> +            ((ShutdownCapable) context).shutdown();
> +        }
> +    }
> +
> +    /**
> +     * Shutdown the logging system if the logging system supports it.
> +     * @param fqcn The fully qualified class name of the Class that this method is a member of.
> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
> +     * @since 2.6
> +     */
> +    protected static void shutdown(final String fqcn, final boolean currentContext) {
> +        shutdown(getContext(fqcn, currentContext));
> +    }
> +
> +    /**
> +     * Shutdown the logging system if the logging system supports it.
> +     * @param fqcn The fully qualified class name of the Class that this method is a member of.
> +     * @param loader The ClassLoader for the context. If null the context will attempt to determine the appropriate
> +     *            ClassLoader.
> +     * @param currentContext if false the LoggerContext appropriate for the caller of this method will be used.
> +     * @since 2.6
> +     */
> +    protected static void shutdown(final String fqcn, final ClassLoader loader, final boolean currentContext) {
> +        shutdown(getContext(fqcn, loader, currentContext));
> +    }
> +
> +    /**
>       * Returns the current LoggerContextFactory.
>       *
>       * @return The LoggerContextFactory.
> 
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java>
> ----------------------------------------------------------------------
> diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
> new file mode 100644
> index 0000000..a46ef60
> --- /dev/null
> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ShutdownCapable.java
> @@ -0,0 +1,17 @@
> +/*
> + * Copyright (c) 2016 Nextiva, Inc. to Present.
> + * All rights reserved.
> + */
> +package org.apache.logging.log4j.spi;
> +
> +/**
> + * Interface to be implemented by LoggerContext's that provide a shutdown method.
> + * @since 2.6
> + */
> +public interface ShutdownCapable {
> +
> +    /**
> +     * Requests that the logging implementation shut down.
> +     */
> +    void shutdown();
> +}
> 
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java>
> ----------------------------------------------------------------------
> diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
> index 48f0eea..596a9f2 100644
> --- a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
> +++ b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
> @@ -17,6 +17,7 @@
>  package org.apache.logging.log4j;
> 
>  import org.apache.logging.log4j.message.ParameterizedMessageFactory;
> +import org.apache.logging.log4j.spi.LoggerContext;
>  import org.junit.Test;
> 
>  import static org.junit.Assert.*;
> @@ -53,4 +54,10 @@ public class LogManagerTest {
>          assertNotNull("No Logger returned", logger);
>          assertTrue("Incorrect Logger name: " + logger.getName(),LogManagerTest.class.getName().equals(logger.getName()));
>      }
> +
> +    @Test
> +    public void testShutdown() {
> +        LoggerContext loggerContext = LogManager.getContext(false);
> +        LogManager.shutdown(loggerContext);
> +    }
>  }
> 
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2df3f0e7/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java>
> ----------------------------------------------------------------------
> diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
> index 42efbb5..fcdfc16 100644
> --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
> +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
> @@ -45,6 +45,7 @@ import org.apache.logging.log4j.message.MessageFactory;
>  import org.apache.logging.log4j.spi.AbstractLogger;
>  import org.apache.logging.log4j.spi.LoggerContextFactory;
>  import org.apache.logging.log4j.spi.LoggerContextKey;
> +import org.apache.logging.log4j.spi.ShutdownCapable;
> 
>  import static org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
> 
> @@ -54,7 +55,7 @@ import static org.apache.logging.log4j.core.util.ShutdownCallbackRegistry.*;
>   * filters, etc and will be atomically updated whenever a reconfigure occurs.
>   */
>  public class LoggerContext extends AbstractLifeCycle implements org.apache.logging.log4j.spi.LoggerContext,
> -        ConfigurationListener {
> +        ShutdownCapable, ConfigurationListener {
> 
>      /**
>       * Property name of the property change event fired if the configuration is changed.
> @@ -278,6 +279,11 @@ public class LoggerContext extends AbstractLifeCycle implements org.apache.loggi
>      }
> 
>      @Override
> +    public void shutdown() {
> +        stop();
> +    }
> +
> +    @Override
>      public void stop() {
>          LOGGER.debug("Stopping LoggerContext[name={}, {}]...", getName(), this);
>          configLock.lock();
>