-
-
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
KLogger obscures location info #11
Comments
I see where the endpoint logging class is set in slf4j: Log4JLoggerAdapter. It seems that changing the FQCN there would be difficult while staying agnostic to the particular logging framework. For now I will opt to handle logging without the KLogging library. Good idea though-- the library came very close to achieving a standardized elegance in Kotlin logging. |
Thanks for raising the issue and the detailed explanation. I will try to On Oct 12, 2016 1:26 AM, "Dylan Hutchison" [email protected] wrote:
|
I think I might be able to solve that. Do you have any test or small On Oct 12, 2016 8:08 AM, "ohad shai" [email protected] wrote:
|
Sorry, I don't have a small project handy at the moment. It should be easy to recreate. Any project that uses slf4j-log4j will run into it. Here's a log4j.xml you can use <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">
<log4j:configuration>
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d{ISO8601} %p %C{1}.%M(%L) - %m%n"/>
</layout>
</appender>
<root>
<level value="INFO"/>
<appender-ref ref="CONSOLE"/>
</root>
</log4j:configuration> |
uncomment line 48 to make the test fail
a possible solution is to do something similar to: https://github.com/qos-ch/slf4j/blob/master/slf4j-ext/src/main/java/org/slf4j/ext/LoggerWrapper.java |
Inlining is fine when the inline functions are extension methods on the On Oct 14, 2016 5:18 AM, "oshai" [email protected] wrote:
|
couple of notes:
|
Changed KLogger to interface and added two implementations: * LocationAwareKLogger that wraps LocationAwareLogger * LocationIgnorantKLogger that wraps the rest of the loggers Added a test for location awerness * removed inline of methods - this is causing troubles in location resolving and stacktraces and not possible on interface
fixed in 1.4 |
Nice job! The inline function logging retained information for me, for some reason. Maybe the Kotlin compiler chose not to inline the functions marked inline. It makes sense that that information would be lost. |
I am using log4j with a patternlayout that includes class, method, and line number information. I expect log statements to print in the form below. This form holds when I manually set
val logger: Logger = LoggerFactory.getLogger(this.javaClass)
.Instead, when I extend a companion object (or any singleton object) with
object : KLogging()
, the following unhelpful information printsThe code responsible for picking the location info is here in LocationInfo. The code sees that KLogger is the immediately logging class on the stack trace and uses KLogger for location info. It should instead use the class immediately below KLogger in the stack trace.
I'm not sure how to fix it, but there should be some hook in the log4j (ideally, slf4j) library that allows manipulating location info.
The text was updated successfully, but these errors were encountered: