This is the default behavior since the very beginning of slf4j, including the latest slf4j-api:2.0.9:
When there's no provider available, slf4j prints an error message to stderr when the library is used for the first time and swallows all logging messages.
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
Can we just log to stdout instead of swallowing the messages?
I know there's a slf4j-simple but it would be much easier to "combine" slf4j-api and slf4j-simple, or just log to stdout/stderr.
The graal native-image gives us an opportunity to build fast command line tools, which will use some existing java libraries. Since slf4j is widely used, a lot of libraries uses slf4j as their logging dependency.
However this requires us to include slf4j-simple for the projects which depend on these libraries.
This is ok for projects running on the server side since it would always need a logging impl anyway, but it's quite redundant for the command-line tools, and it would require extra configurations when building the native-image (we must ensure slf4j-simple accessible and can be used via reflection when building).
So can we consider to simply log to stdout when there is no provider available?
In response to issue 361 the Reporter class has been added. See commit 316b5d1727d647250ff791565650070094f5b85e and commit c12667b9063b2b9409ed49072d9746f34f968440
The Reporter class will be part of the next release.
This is the default behavior since the very beginning of
slf4j
, including the latestslf4j-api:2.0.9
:When there's no provider available, slf4j prints an error message to stderr when the library is used for the first time and swallows all logging messages.
Can we just log to stdout instead of swallowing the messages?
I know there's a
slf4j-simple
but it would be much easier to "combine"slf4j-api
andslf4j-simple
, or just log to stdout/stderr.The graal
native-image
gives us an opportunity to build fast command line tools, which will use some existing java libraries. Sinceslf4j
is widely used, a lot of libraries uses slf4j as their logging dependency.However this requires us to include
slf4j-simple
for the projects which depend on these libraries.This is ok for projects running on the server side since it would always need a logging impl anyway, but it's quite redundant for the command-line tools, and it would require extra configurations when building the native-image (we must ensure
slf4j-simple
accessible and can be used via reflection when building).So can we consider to simply log to stdout when there is no provider available?