Skip to content
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

Prevent logging? #3901

Closed
gchaperon opened this issue May 2, 2021 · 6 comments
Closed

Prevent logging? #3901

gchaperon opened this issue May 2, 2021 · 6 comments
Labels

Comments

@gchaperon
Copy link
Contributor

Is it currently possible to prevent logging completely?

I am looking at the source and it seems to me that it is not possible, since only valid names defined in spoon.support.Level are allowd here

private Level toLevel(String level) {

Please let me know if I have overlooked something and it is actually possible.

If it is not possible, how would you feel about adding OFF(0) to Level. Would that allow to turn logging completely off?

Best,
Gabriel.

@slarse
Copy link
Collaborator

slarse commented May 2, 2021

Hi @gchaperon,

I see no reason not to offer that. I'd say it's rather unexpected to find that you can set logging levels, but none of them allow you to disable logging entirely.

Care to do a PR? :)

@monperrus
Copy link
Collaborator

monperrus commented May 3, 2021 via email

@slarse
Copy link
Collaborator

slarse commented May 3, 2021

In theory, the logging can be entirely disabled via slf4j (by configuring logback in logback.xml)

Ah, yes, that is true. But as we have an API for setting the logging level, wouldn't it also make sense to add an OFF level? It wouldn't be much effort at all, just adding the level to Level and then patching up the switch statement that deals with logging in StandardEnvironment.

@monperrus
Copy link
Collaborator

But as we have an API for setting the logging level, wouldn't it also make sense to add an OFF level?

yes it would!

@slarse slarse added the feature label May 3, 2021
@slarse
Copy link
Collaborator

slarse commented May 3, 2021

yes it would!

Let's put it on the TODO list then :)

@gchaperon Would you like to try your hand at a PR for this feature?

@gchaperon
Copy link
Contributor Author

hi, ya sure, i can try
looking more in detail I have a question.
i see that this method is only used internally, so the setLevel config on StandardEnvironment only applies to the logging produced by that class. I think this is somewhat confusing for the user, shouldn't be all logging managed by slf4j?

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

No branches or pull requests

3 participants