From slf4j-dev at qos.ch Mon Nov 6 20:05:00 2023 From: slf4j-dev at qos.ch (slf4j developers list) Date: Mon, 6 Nov 2023 20:05:00 +0000 (UTC) Subject: [slf4j-dev] [JIRA] Updates for SLF4J-592: Mechanism for indicating provider to use for unit tests. In-Reply-To: References: Message-ID: SLF4J / SLF4J-592 [Resolved] Mechanism for indicating provider to use for unit tests. ============================== Here's what changed in this issue in the last few minutes. There is 1 comment. View or comment on issue using this link https://jira.qos.ch/browse/SLF4J-592 ============================== 1 comment ------------------------------ Garret Wilson on 06/Nov/23 19:53 [~ceki] I want to say thanks for the discussion here on how to have different logging implementations for unit tests. You've marked this ticket as a duplicate of SLF4J-450. That's fine, although I would say that SLF4J-450 is one possible way to address this larger issue. In fact I want to step back and reevaluate what I was trying to do in the beginning and give a summary for the record. I opened this ticket because I wanted to see any log output of my unit tests to {{stdout}}. At least I thought I did. But upon reflection I don't want to see all that logging stuff in the output of my Maven build. what I _really_ want is to _disable_ the logging for unit tests, but somehow easily turn them on arbitrarily when I'm debugging my unit tests. Disabling the output is easy—sort of: I can just do nothing, and SLF4J will fall back to a NOP provider, but it will still show some ugly logging. It turns out I can play some tricks with SLF4J-450 to get around that. And to arbitrarily turn on logging to {{stdout}}, again I can play some tricks with SLF4J-450. So in the end I think {{SLF4J-450}} will allow me to do what I (discovered that I really) want to do, and I'll wind up taking {{slf4j-simple}} out of my root POM altogether. I'm going to implement this in my [Clogr](https://clogr.io/) library. I'll come back and add one more update here to explain how it all fits together. Note that ============================== This message was sent by Atlassian Jira (v9.6.0#960000-sha1:a3ee8af) From slf4j-dev at qos.ch Mon Nov 6 22:00:00 2023 From: slf4j-dev at qos.ch (slf4j developers list) Date: Mon, 6 Nov 2023 22:00:00 +0000 (UTC) Subject: [slf4j-dev] [JIRA] Updates for SLF4J-592: Mechanism for indicating provider to use for unit tests. In-Reply-To: References: Message-ID: SLF4J / SLF4J-592 [Resolved] Mechanism for indicating provider to use for unit tests. ============================== Here's what changed in this issue in the last few minutes. There is 1 comment. View or comment on issue using this link https://jira.qos.ch/browse/SLF4J-592 ============================== 1 comment ------------------------------ Garret Wilson on 06/Nov/23 21:49 As of [JAVA-356|https://globalmentor.atlassian.net/browse/JAVA-356] I've removed {{slf4j-simple}} from the root POM so that it won't be added to the test scope anymore, and as of [CLOGR-14|https://globalmentor.atlassian.net/browse/CLOGR-14] the next version of Clogr will allow me to do the following in any unit tests to suppress logging output altogether (so that they don't add junk to Maven builds, for example). {code:java} @BeforeAll static void suppressLogging() { setSystemDefaultLoggingProviderNop(); } {code} This will do for now to clean up the build output. Once [#361|https://github.com/qos-ch/slf4j/issues/361] is addressed to disable the extra , I'll use SLF4J-450 to turn off logging in the Maven build altogether [using Surefire|https://maven.apache.org/surefire/maven-surefire-plugin/examples/system-properties.html] as discussed in this ticket. Then I'll add a simple {{stderr}} provider that doesn't advertise itself to SLF4J, but that I can still programmatically select in the unit tests, so that with SLF4J-450 I can then still run the test in the IDE and see output in {{stderr}}, but have Maven Surefire set {{slf4j.provider}} to the NOP provider so that the full build doesn't show anything. I guess the only thing preventing me from doing this last part already is that {{slf4j-simple}} advertises itself as a provider just by including it. It would be nice if there were two separate libraries, one for {{slf4j-simple}} and the other for {{slf4j-simple-provider}}. But no worries—I can write my own. ============================== This message was sent by Atlassian Jira (v9.6.0#960000-sha1:a3ee8af)