[
https://issues.apache.org/jira/browse/LOG4J2-1117?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Gary Gregory resolved LOG4J2-1117.
----------------------------------
Resolution: Fixed
Fix Version/s: 2.4
Thank you for your report and digging into the code.
The keys look fishy to me as well.
I've committed a patch to Git master to use the same key in both places you
mention.
Please verify and close this ticket.
> 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
> Fix For: 2.4
>
>
> 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 output.
> 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
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]