logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Gregory (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (LOG4J2-1539) Add Core API Configurator.shutdown(LoggerContext, long, TimeUnit)
Date Tue, 23 Aug 2016 22:59:21 GMT

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

Gary Gregory edited comment on LOG4J2-1539 at 8/23/16 10:58 PM:
----------------------------------------------------------------

Looking at this last night I realized that if we add a {{LoggerContext}} to {{Configuration}},
then we do not need to add an annotation like {{@PluginLoggerContext}} like we have {{@PluginConfiguration}}
since the logger context would be accessible from the configuration. So if your appender or
manager needs a {{LoggerContext}}, it just needs to implement a builder with {@PluginConfiguration}}
and you're done. No need to clutter up the config code with more annotations and annotation
processing logic.


was (Author: garydgregory):
Looking at this last night I realized that if we add a LoggerContext to Configuration, then
we do not need to add an annotation like {{@PluginLoggerContext}} like we have {@PluginConfiguration}}
since the Logger context would be accessible from the Configuration. So if your appender or
manager needs a LoggerContext, it just needs to implement a builder with {@PluginConfiguration}}
and you're done. No need to clutter up the config code with more annotations and annotation
processing logic.

> Add Core API Configurator.shutdown(LoggerContext, long, TimeUnit)
> -----------------------------------------------------------------
>
>                 Key: LOG4J2-1539
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1539
>             Project: Log4j 2
>          Issue Type: New Feature
>          Components: Core
>            Reporter: Gary Gregory
>             Fix For: 2.7
>
>         Attachments: logging-log4j2.patch
>
>
> Add Core API Configurator.shutdown(LoggerContext, long, TimeUnit):
> {code:java}
>     /**
>      * Blocks until all Log4j tasks have completed execution after a shutdown request,
or the timeout occurs, or the
>      * current thread is interrupted, whichever happens first.
>      * <p>
>      * Log4j can start threads to perform certain actions like file rollovers, calling
this method with a timeout will
>      * block until the rollover thread is done.
>      * </p>
>      * 
>      * @param ctx
>      *            the logger context to shut down, may be null.
>      * @param timeout
>      *            the maximum time to wait
>      * @param timeUnit
>      *            the time unit of the timeout argument
>      * @return {@code true} if the logger context terminated and {@code false} if the
timeout elapsed before
>      *         termination.
>      */
>     public static boolean shutdown(final LoggerContext ctx, final long timeout, final
TimeUnit timeUnit)
> {code}
> Clarify the existing Javadoc for {{shutdown(LoggerContext}} as:
> {code:java}
>     /**
>      * Shuts down the given logger context. This request does not wait for Log4j tasks
to complete.
>      * <p>
>      * Log4j starts threads to perform certain actions like file rollovers; calling this
method will not wait until the
>      * rollover thread is done. When this method returns, these tasks' status are undefined,
the tasks may be done or
>      * not.
>      * </p>
>      * 
>      * @param ctx
>      *            the logger context to shut down, may be null.
>      */
>     public static void shutdown(final LoggerContext ctx)
> {code}
> This also eliminates all intermittent failures in rollover unit tests like {{org.apache.logging.log4j.core.appender.rolling.RollingAppenderCronTest.testAppender}}.



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

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


Mime
View raw message