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

Add a modifiable factory for SLF4J loggers #434

Open
freya022 opened this issue Jul 13, 2024 · 2 comments
Open

Add a modifiable factory for SLF4J loggers #434

freya022 opened this issue Jul 13, 2024 · 2 comments

Comments

@freya022
Copy link

freya022 commented Jul 13, 2024

I think it would be nice if we could set our own way to get a org.slf4j.Logger from the name, for example this could allow returning a fallback logger, when no logging implementation is detected, in this example I could use this method.

I assume this could be implemented by having a mutable property in KotlingLogging, which would get used by KLoggerFactory.logger.

This would also avoid checking the kotlin-logging-to-jul property for every logger, by checking once and using the right factory.

Caveats

This is modifiable by anyone, it could get overwritten by accident by an end user of a library that did set that property

Workarounds

Use your own function to get a KLogger

Copy link

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

@oshai
Copy link
Owner

oshai commented Jul 18, 2024

I think maybe a better approach is to implement the fallback logger you linked in this lib. I saw many cases that logging was misconfigured in slf4j, and their approach of not logging info messages in that case is something we can consider to change.

Ref: https://stackoverflow.com/questions/56270497/how-to-get-slf4j-console-output-when-no-implementation-is-present

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