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

Incorrect file name and line number #17

Closed
wafisher opened this issue Feb 28, 2017 · 11 comments
Closed

Incorrect file name and line number #17

wafisher opened this issue Feb 28, 2017 · 11 comments

Comments

@wafisher
Copy link

For my logback.xml configuration of:

<pattern>... \(%F:%L\) %msg%n</pattern>

I'm consistently getting file name / line number in the KLogger file (KLogger.kt:23) for all my debug statements, which is precisely where KLogger itself calls debug().

I'm using 1.4.2 so #11 shouldn't apply. This happens when I use val logger = LoggerFactory.getLogger("class name") or private val logger = KotlinLogging.logger {}.

Thanks!

@oshai
Copy link
Owner

oshai commented Feb 28, 2017

Can you please share a repo that reproduces it?

@oshai
Copy link
Owner

oshai commented Feb 28, 2017

And another question - when you use slf4j directly do you get correct location? If not it's probably a configuration issue.

@wafisher
Copy link
Author

wafisher commented Mar 1, 2017

Yes, the location is definitely right when using LOG from slf4j.

Our codebase is not open source so it's a little hard to point you at something. Is there any idea you might have that would help me debug it? It does seem to be using a LocationAware version of the logger.

@wafisher
Copy link
Author

wafisher commented Mar 1, 2017

I'm getting the following with %caller:

Caller+0	 at mu.KLogger$DefaultImpls.info(KLogger.kt:30)
Caller+1	 at mu.internal.LocationAwareKLogger.info(LocationAwareKLogger.kt:13)
Caller+2	 at com.bowerylabs.position.ml.MainKt.main(Main.kt:37)
Caller+3	 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

And then %F:%L will be KLogger.kt:30 which is not what I care about. I want to see Main.kt:37. Is that possible? I understand why it does this since the real call to info is, indeed, at line 30 of KLogger.kt

@oshai
Copy link
Owner

oshai commented Mar 1, 2017

Here is what I suspect: LocationAwareKLogger has a field called fqcn which is the name of the class LocationAwareKLogger. I think that it is because some methods has default implementation in 'KLogger' which was not overriden in LocationAwareKLogger. it is solvable by just overriding all the methods. I will add a test to check that, but you can as well try to call a method like logger.info("test") [not the lambda flavour].

@wafisher
Copy link
Author

wafisher commented Mar 1, 2017

Just tested and you're right, the non-lambda flavor works perfectly!

@oshai
Copy link
Owner

oshai commented Mar 1, 2017

that is what I suspected - I will create a fix for it and release 1.4.3

oshai added a commit that referenced this issue Mar 1, 2017
implemented all log methods in location aware logger
@oshai
Copy link
Owner

oshai commented Mar 1, 2017

I wasnt able to reproduce it - I think because it doesnt happen with log4j implementation. anyway I will release 1.4.3 and we will make sure it fix the issue.

@wafisher
Copy link
Author

wafisher commented Mar 1, 2017

Great thank you for the quick turnaround.

@oshai
Copy link
Owner

oshai commented Mar 1, 2017

1.4.3 is deployed. let me know if it was solved.

@wafisher
Copy link
Author

wafisher commented Mar 1, 2017

Fixes it for me.

@oshai oshai closed this as completed Mar 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants