-
Notifications
You must be signed in to change notification settings - Fork 123
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 line number when using Slf4jLoggerBackend #140
Comments
I'm afraid the SLF4J backend was a community contributed backend and isn't supported directly by Google. If you want to dig into the code and look for a solution I can probably answer some questions, or perhaps you can reach out to the original author ( https://github.com/cslee00 ) |
Originally authored the SLF4J back-end. Due to the SLF4j API the Flogger
back-end simply uses SLF4J in the same manner as calling code would, e.g.
obtaining loggers via LoggerFactory.getLogger. The SLF4J API doesn't offer
a means to provide call-site information - for SLF4J that's a back-end
consideration. What SLF4J binding is in use?
If the configured SLF4J back-end supports configuration of call-site
resolution it should be setup to grab callers
of com.google.common.flogger.FluentLogger#forEnclosingClass (or your custom
Flogger logger class, if any).
Chris.
…On Tue, 24 Mar 2020 at 05:31, David Beaumont ***@***.***> wrote:
I'm afraid the SLF4J backend was a community contributed backend and isn't
supported directly by Google. If you want to dig into the code and look for
a solution I can probably answer some questions, or perhaps you can reach
out to the original author ( https://github.com/cslee00 )
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#140 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABCCXPQE2CZ6BF6IIM2C53TRJCR2ZANCNFSM4LNRE6SA>
.
|
Hi, Thanks for the replies. I'm using log4j2 - log4j-slf4j-impl version 2.13.1 |
""If the configured SLF4J back-end supports configuration of call-site That's probably not a great way to do this. You're better off (if the API allows) to use the LogSite that's available in the LogData. If the API doesn't allow it, then would you be better using the Flogger backend that talks directly to the backend you have (e.g. Log4J2). The logger that logs things and the classes the log statements are in are not necessarily the same. |
Hi,
I see that log4j2 was added recently. I prefer to use log4j2 directly if possible but I noticed some issue with that as well (Opened issue #144). Thanks! |
I'll personally not work on this (no time) but I will see about looking into the Log4j2 issue and see if that's easy enough. |
@hagbard Thank you. I appreciate that. |
Hi,
I'm using Flogger with slf4j+log4j2 backend and a pattern that includes the line number (%line).
The line number in the log message does not match my code but instead matches the log statements inside Slf4jLoggerBackend
flogger/slf4j/src/main/java/com/google/common/flogger/backend/slf4j/Slf4jLoggerBackend.java
Line 196 in 2a67023
Attaching a small project that reproduces the issue.
line-number-test.zip
Output:
The expectation is that the line number will match the log statement in the LogTest. Accurate line number is very important in our log messages.
Thanks.
The text was updated successfully, but these errors were encountered: