Closed MzrW closed 1 month ago
Thank you for reporting an issue. See the wiki for documentation and slack for questions.
The difference seems to be inside LocationAwareKLogger
.
Log statements without payload are logged using: org.slf4j.spi.LocationAwareLogger.log(org.slf4j.Marker marker, String fqcn, int level, String message, Object[] argArray, Throwable t)
Log statements with payload are logged using:
org.slf4j.spi.LoggingEventBuilder.log(String message)
.
LocationAwareKLoggger.logWithPayload seems to correctly set the callerBoundary.
The first thing org.slf4j.spi.DefaultLoggingEventBuilder.log(String message)
does is to override the callerBoundary with its own classname.
Therefore I think the bug is inside slf4j not in kotlin-logging.
Maybe leave the issue open until the bug is resolved there ...
Are you using log4j? There was a related bug there.
No Im using slf4j-jdk the java util logging.
Log4j slf4j issue is here for reference: https://github.com/apache/logging-log4j2/issues/1533
It might be a similar fix.
Seems like this should be fixed in slf4j 2.0.13. I will try to upgrade.
Seems like this should be fixed in slf4j 2.0.13. I will try to upgrade.
should be in version 6.0.9.
When using slf4j version 2.0.13 the correct class name is logged. @oshai feel free to close the issue.
Thanks!
The wrong class name is printed when using the LoggingEventBuilder with a payload.
The following example demonstrates the issue:
Which will print:
The first log statement will be logged with
io.github.oshai.kotlinlogging.slf4j.internal.LocationAwareKLogger
as a classname. Which is wrong. It supposed to bemy.pkg.MyClassKt
.In the second log statement however it seems to work fine.
Check out the example to reproduce the issue: example.zip