Skip to content

Feature to allow suppressing unsuccessful init error message #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

hohwille
Copy link

@hohwille hohwille commented Aug 4, 2016

As you can read in m-m-m/util#194 there are cases where one uses slf4j in general library code that is also used in command-line-interface (CLI) programs.
In my case I want to ship the CLI library without any logger binding for slf4j in order to give users the freedom to choose on their own. However the CLI library already contains CLI programs by itself. If you want to run them without additional dependencies you get a warm welcome from slf4j saying:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

In case of a CLI program this output is really undesired.

I tried to be constructive and provide a minimal invasive "fix" for the problem that allows to suppress this output by setting a system property slf4j.suppressInitError (I tried to follow your current code and naming conventions) to true.

You can also add a public static non-arg method to LoggerFactory that sets the system property to true for you if you like. Also you can think of a system property that enforces nop logger no matter what is on your classpath. But as stated before I wanted to keep the change and impact minimal so I hopefully have a high change to get this PR accepted and you see this as a helpful improvement to slf4j. Thanks in advance.

@hohwille
Copy link
Author

hohwille commented Mar 7, 2018

completely redone as master changed and merge was not possible anymore.

@qos-ch qos-ch deleted a comment from LoneDev6 Nov 22, 2022
@hohwille
Copy link
Author

No reaction after 6.5 years?

@ceki
Copy link
Member

ceki commented Feb 18, 2023

Filing a jira issue would have helped this PR getting more attention as explained at the project's home page..

As you write, the PR is non-invasive which is good. However, for a CLI, adding slf4j-nop would work as well. As such, I am closing this PR without merging.

@ceki ceki closed this Feb 18, 2023
@hohwille
Copy link
Author

However, for a CLI, adding slf4j-nop would work as well. As such, I am closing this PR without merging.

This works if the users of the CLI library know about such things. However, users will try out the library and then see this SLF4J output messing the help page. Then they tell me that my library is shit. Unfortunately that is how life works. I can not include slf4j-nop myself as then other users that want to use a real logger writing to a file while the CLI is only producing basic output.

@ceki
Copy link
Member

ceki commented Feb 18, 2023

How about including slf4j-simple which Maven uses? It is still quite configurable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants