logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simon Cooper (JIRA)" <j...@apache.org>
Subject [jira] [Created] (LOG4J2-1794) Programmatic reconfiguration doesn't affect existing loggers
Date Thu, 19 Jan 2017 12:55:26 GMT
Simon Cooper created LOG4J2-1794:

             Summary: Programmatic reconfiguration doesn't affect existing loggers
                 Key: LOG4J2-1794
                 URL: https://issues.apache.org/jira/browse/LOG4J2-1794
             Project: Log4j 2
          Issue Type: Bug
          Components: Configurators
    Affects Versions: 2.7
            Reporter: Simon Cooper

Sample code:

{code}    private static final Logger Log = LogManager.getLogger();

    public static void main(String[] args) throws Throwable {
        ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory.newConfigurationBuilder();
        AppenderComponentBuilder console = builder.newAppender("Stdout", "Console")
                .addAttribute("follow", true)
                .add(builder.newLayout("PatternLayout").addAttribute("pattern", "Format: %m%n"));


The log statement at the bottom doesn't use the specified format, it uses the existing format.
If the {{private static final Log = ...}} statement at the top is commented out, the log *does*
use the reconfigured format.

Reconfiguring the log settings should affect any loggers already created. Waiting until the
logging is configured before creating any loggers is not always feasible - for example, if
your entrypoint class has a static {{Logger}} and the reconfiguration is being done by a library
you're calling into.

This message was sent by Atlassian JIRA

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

View raw message