Details
-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
None
-
None
Description
I am using the kotlin-logging library which is basically a wrapper around slf4j tailored for kotlin. (Original issue kotlin-logging-416).
When logging using the LoggingEventBuilder and setting the CallerBoundary accordingly it prints the wrong classname.
package my.pkg; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.spi.CallerBoundaryAware; public class Example { private static final LoggingWrapper wrapper = new LoggingWrapper(); public static void main(String[] args) { wrapper.logWithEvent("hello"); } } class LoggingWrapper { private Logger underlyingLogger = LoggerFactory.getLogger("anything"); public void logWithEvent(String msg) { var builder = underlyingLogger.atInfo(); // setting the caller boundary to LoggingWrapper if(builder instanceof CallerBoundaryAware) ((CallerBoundaryAware) builder).setCallerBoundary(LoggingWrapper.class.getName()); builder.log(msg); } }
Running the given example I expect the following output:
Apr. 06, 2024 6:28:12 AM my.pkg.Example main
INFORMATION: hello
However following is printed:
Apr. 06, 2024 6:28:12 AM my.pkg.LoggingWrapper logWithEvent
INFORMATION: hello
Checkout the example: example.zip
Attachments
Issue Links
- links to