-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
How to set project loglevel #20
Comments
I saw a similar question on SO: http://stackoverflow.com/questions/43146977/how-to-configure-kotlin-logging-logger |
updated the frequently asked questions |
Despite the FAQ entry I believe we desperately need a concrete example on how to set the log level when using e.g. logback as the logger implementation. I have in
And in my
But that gives
So how am I supposed to access the logger implementation via kotlin-logging in order to call the logger implementation-specific code to set the log level? |
I think I understand the issue you mention. What I suggest is to add to the KLogger interface a method - getUnderlyingLogger() or something similar that will provide the underlying log implementation which can be casted to ch.qos.logback.classic.Logger in the case of logback. What do you think about this solution? |
That would probably work, although it seems a tad inconvenient. That is, slightly less convenient than being able to just casting the main class.
But that does not seem to be usable if I need to change the log level at runtime triggered by external events (potentially multiple times). |
I can add that, probably a property |
Well, given that I just migrated to slf4k because of that missing feature, probably not right away, but I'll certainly give it a try in one of my next projects. |
ok, I will add that to 1.4.6.
…On Tue, Jul 11, 2017 at 9:45 PM, Sebastian Schuberth < ***@***.***> wrote:
will you use that if such exists?
Well, given that I just migrated to slf4k because of that missing feature,
probably not right away, but I'll certainly give it a try in one of my next
projects.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#20 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACj0QYANW6kVho2ylzmT74LCLZ3MidSlks5sM8LPgaJpZM4M0wmA>
.
|
1.4.6 released |
SimpleLogger cannot set the log level at runtime, and kotlin-logging does not seem to expose a way to access the actual logger implementation in order to set the log level, see oshai/kotlin-logging#20 (comment) Change-Id: I8f769fc4113bff25ac2dc84732862523025edd68
This works pretty well with import ch.qos.logback.classic.Level
import ch.qos.logback.classic.Logger
var mu.KLogger.level
get() = (underlyingLogger as Logger).level
set(value) { (underlyingLogger as Logger).level = value }
logger.level = Level.DEBUG
logger.level //=> Level.DEBUG |
This is already an old thread but the topic fits my question. How do you set the log level for the non-JVM targets. What is the underlying logger in that case? I am specifically asking for iOS and wasmJs. |
See: https://github.com/oshai/kotlin-logging/wiki/Multiplatform-support |
Via your link I finally found the solution but the description in there is wrong. |
I updated the wiki. |
Hi,
Thanks for putting this library together. In using kotlin, I was putoff by the long/complex answers to the simple question "how do you log in kotlin (http://stackoverflow.com/questions/34416869/idiomatic-way-of-logging-in-kotlin)".
I'm using Klogging as follows:
This works nicely, but when I do
logger.debug
, my IntelliJ IDEA run console doesn't show any output. Do you know how I could set the console logger to debug or trace levels? Is this an IDE setting, or can it be set in the call toKLogging()
?The text was updated successfully, but these errors were encountered: