[slf4j-dev] [JIRA] (SLF4J-389) SimpleLogger caches System.err and System.out

QOS.CH (JIRA) noreply-jira at qos.ch
Wed Feb 15 11:00:00 CET 2017


    [ https://jira.qos.ch/browse/SLF4J-389?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18173#comment-18173 ] 

Ceki Gülcü commented on SLF4J-389:
----------------------------------

Hi [~michael-o], 

On January 111th, I have posted [a message on the maven-dev mailing list|http://markmail.org/message/5x2dpmy3szzfiv5k] inquiring whether this change could have any effect on Maven. There was no response to this message.

To answer your question, there's a possibility that Maven would be affected if if a given plugin modifies the value of System.out or System.err and further assumes that Maven’s log output will be directed to the old value of the stream. I can't say for sure.

In any case, if Maven is affected,  the old behavior can be re-introduced as a  configuration option.  Please let me know what you think.



> SimpleLogger caches System.err and System.out
> ---------------------------------------------
>
>                 Key: SLF4J-389
>                 URL: https://jira.qos.ch/browse/SLF4J-389
>             Project: SLF4J
>          Issue Type: Bug
>    Affects Versions: 1.7.x
>            Reporter: Igor Polevoy
>            Assignee: Ceki Gülcü
>             Fix For: 1.7.23
>
>
> We usually use SimpleLogger in tests, and some other binding when running  in production. 
> In some cases, our tests depend on log values logged through the logger during a test. 
> Unfortunately between version 1.7.0 and 1.7.1 this ability has been removed, since the SimpleLogger now caches the system stream in a static initialiser. 
> Here is the code that broke this approach: 
> https://github.com/qos-ch/slf4j/commit/996ccc7ca507994465c069554954ecb01890d4d5
> Basically, we would write a test: 
> {quote}PrintStream err = System.err; 
> PrintStream temp = new PrintStream(some buffer here);
> System.err = temp;
> // run tests
> System.err = err;
> // here we assert that the temp stream contains values we expect{quote}
> Unfortunately SimpleLogger now caches the system stream and never releases it, meaning swapping the streams to catch the output is not possible. 



--
This message was sent by Atlassian JIRA
(v7.3.1#73012)


More information about the slf4j-dev mailing list