google / google/flogger

Incorrect caller details logged with Flogger in spring boot

Open
#360 3 comments 0 reactions 0 assignees View on GitHub
P4
Dominant language
Java
Stars
1.5k
Forks
133
Avg merge
6m
Merged PRs (30d)
7

Description

I am using Flogger API to log details in my spring boot controller, I am using below dependency for logging:

```

com.google.flogger
flogger-slf4j-backend
0.7.4

```

I need to log caller details like class name, method name and line number. so, I have been using this log pattern in logback.xml file.

`Class:%class{36} Method:%method Line:%line`

With Fluent API:

` log.atInfo().log(">>>>>>>>>>>>>>Test>>>>>>>>>>>>>>>>");`

It logs:

`"Class1":"c.g.c.f.b.slf4j.Slf4jLoggerBackend","Method1":"log","Line1":"176"`

So, its logging internal details. Not the current Controller class or method name, which is DemoController and test method here.

However, It logs properly with @Slf4j or with log.info and log.debug etc

Can anyone pls suggest how to log correct caller details with Flogger API.

Also raised: https://stackoverflow.com/questions/77042586/what-is-the-log-pattern-to-log-caller-details-with-flogger-in-spring-boot

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.