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

setting logging level per KLogger instance in run-time #369

Closed
vak opened this issue Nov 8, 2023 · 4 comments
Closed

setting logging level per KLogger instance in run-time #369

vak opened this issue Nov 8, 2023 · 4 comments

Comments

@vak
Copy link

vak commented Nov 8, 2023

Q: is it possible to set the logging level in a run-time not globally, but per KLogger-instance?

Ideally it should be agnostic of underlying logging framework. That is, it would be ideally done within this kotlin-logging library via some setLogLevel member function.

This would be extremely useful for enabling individual log-levels for different modules, class instances, etc.

Unfortunately, logging is a deep ocean, we'd be happy to swim across it without sinking in underlying logging frameworks :-)

Copy link

github-actions bot commented Nov 8, 2023

Thank you for reporting an issue. See the wiki for documentation and slack for questions.

@oshai
Copy link
Owner

oshai commented Nov 8, 2023

Thanks for raising the issue. I don't think I have a good answer ready for you, but I will write few thoughts.
The lib started as a facade for JVM and as such it delegates everything to the underlying (slf4j) framework. In jvm, not all frameworks support dynamically change of level.
Now in multi-platform it somehow makes sense as the lib act as a low level lib (not facade). It mostly makes sense for platforms inherit from direct. I am not sure what platform you had in mind, but we can continue the discussion from there.

@vak
Copy link
Author

vak commented Nov 10, 2023

@oshai, thank you for responding. I am using Kotlin on a daily basis for 1 year only and am still quite shallow on JVM ecosystem. Therefore I asked my colleagues for help on this part :-)

However, my naive hope is that such setLogLevel() function should either set the log level if it is supported by underlying logging framework or it should just spit an error once "can't set logging level for ..." without any effect if the underlying logging framework doesn't support this.

@oshai
Copy link
Owner

oshai commented Nov 12, 2023

You can see some more details how to do it in here. Right now I don't have any plans to add it to the lib.

@oshai oshai closed this as completed Apr 14, 2024
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

No branches or pull requests

2 participants