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

Use SLF4J as default logger #130

Closed
scottsteen opened this issue May 15, 2018 · 7 comments
Closed

Use SLF4J as default logger #130

scottsteen opened this issue May 15, 2018 · 7 comments

Comments

@scottsteen
Copy link

Is your feature request related to a problem? Please describe.
Having this as part of a production project isn't feasible without using a real logging implementation.

Describe the solution you'd like
An implementation of the koin Logger that uses SLF4J should be the default logger. If this isn't possible for Android apps, then could it be overriden as part of the android specific project?

Describe alternatives you've considered
Implementing my own is possible, but I'd prefer not to re-implement this in every project using Koin.

Target Koin project
koin-core (possibly also koin-android)

@erickok
Copy link
Contributor

erickok commented May 16, 2018

Please don't. It is trivial to implement Koin's Logger interface and there is no reason to have a dependency on any external logging library.

@scottsteen
Copy link
Author

I did as you suggested, but Koin still prints some statements before my code to set the logger is executed. I'm building using Koin as part of a Ktor project, so don't have control over the program's entry point. Writing anything to stdout is dangerous, so the current implementation could be seen by many as a blocker to using such a great library.

Would you consider switching the default logger to Java Util Logging instead? Or even to have a service locator to allow me to change the logger by config, rather than programmatically?

@erickok
Copy link
Contributor

erickok commented May 16, 2018

Sure, I agree Koin should not log anything by default. cf #50

@arnaudgiuliani
Copy link
Member

Koin is just providing a default way to Log. Each project has to define its way of logging.

For ktor & spark, we can provide a koin-logger-slf4j project implementation. I agree it's a missing part, but not a standard component from the core.

@erickok
Copy link
Contributor

erickok commented May 17, 2018

But why is it logging anything by default? I find that a bad practise, IMHO.

@arnaudgiuliani
Copy link
Member

koin-core is not linked to any logging solution. Logging solution is a link from to your target runtime. For spark & ktor, it will be logged via slf4j. It's just a missing piece.

You can configure logging before starting Koin container, with Koin.logger = <Your impl>

Spring framework & Ktor are logging by default ... why koin logging should be a bad thing?

@arnaudgiuliani
Copy link
Member

The point can be instead - log in debug level for the logging solution and let the user log it or not via its logging config.

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

No branches or pull requests

3 participants