[slf4j-dev] [JIRA] Updates for SLF4J-592: Mechanism for indicating provider to use for unit tests.

slf4j developers list slf4j-dev at qos.ch
Mon Nov 6 22:00:00 UTC 2023


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)



More information about the slf4j-dev mailing list