google / google/flogger

Incorrect line number when using Slf4jLoggerBackend

Open
#140 7 comments 0 reactions 0 assignees View on GitHub
P3 type=defect
Dominant language
Java
Stars
1.5k
Forks
133
Avg merge
6m
Merged PRs (30d)
7

Description

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 https://github.com/google/flogger/blob/2a6702386859e94c274c79dfad5830d36455d25b/slf4j/src/main/java/com/google/common/flogger/backend/slf4j/Slf4jLoggerBackend.java#L196

Attaching a small project that reproduces the issue.

[line-number-test.zip](https://github.com/google/flogger/files/4344159/line-number-test.zip)

Output:
```
2020-03-17T17:10:53,709 [main] INFO example.LogTest:208 - Info
2020-03-17T17:10:53,712 [main] WARN example.LogTest:211 - Warn
2020-03-17T17:10:53,712 [main] ERROR example.LogTest:214 - Severe
```

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.