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] [Assigned] (LOG4J2-1117) OutputStreamManager in ConsoleAppender leaking managers?
Date Fri, 11 Sep 2015 23:40:45 GMT

     [ https://issues.apache.org/jira/browse/LOG4J2-1117?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

Gary Gregory reassigned LOG4J2-1117:

    Assignee: Gary Gregory

> OutputStreamManager in ConsoleAppender leaking managers?
> --------------------------------------------------------
>                 Key: LOG4J2-1117
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1117
>             Project: Log4j 2
>          Issue Type: Bug
>    Affects Versions: 2.1
>            Reporter: Marcus Thiesen
>            Assignee: Gary Gregory
>            Priority: Minor
> I'm actually confused about the intention here, so this is more a question than a bug
report, though I'm quite sure that something is wrong here.
> I ran into this issue while writing unit tests for a custom layout and using InitialLoggerContext
to setup my logging. I was expecting to always get a fresh start with my actual logger. And
I always set a new custom PrintStream for System.out in order to capture the finished output.

> That just worked once, even when I set "follow" ("If true will follow changes to the
underlying output stream.") on the console appender, due to the caching in the AbstractManager/OutputSteamManager
> The issue is that ConsoleAppender.getManager does the following:
> OutputStreamManager.getManager(target.name() + '.' + follow, new FactoryData(os, type,
layout), factory);
> So the key that ends up in AbstractManager.MAP is something like "SYSTEM_OUT.true". ConsoleAppenders.ConsoleManagerFactory
just uses data.type as the name for the manager, so this will be something like "SYSTEM_OUT"
in this case.
> But AbstractManager.release uses the "name" field of the Manager for removing from the
map, thus an entry with "SYSTEM_OUT.true" will never be removed, which leads to the issue
that changes to System.out will not be visible for the ConsoleAppender.

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