google / google/flogger

Unexpected suffix in log messages

Open
#299 0 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

After upgrade from flogger 0.6 to flogger 0.7.1 I am observing an unexpected suffix in our log messages. We are using flogger-system-backend and flogger-grpc-context maven dependencies.

We are using context based log levels. We have code like:

final var logLevelMap = buildLogLevelMap();
ScopedLoggingContext.getInstance()
.newContext()
.withLogLevelMap(logLevelMap)
.install();

For example if I have a log statement like:

log.atFine().log("My message");

Then I will see the log record message as "My message [CONTEXT forced=true ]".

I have made a couple observations from the debugger:

1. GrpcContextData::shouldForceLoggingFor method seems to return true for all cases where the message should be logged according the the log level map, regardless of whether the message would have been logged anyway according to system log levels. So once we start using the log level map I am seeing the suffix get added for every single log message.
2. LogContext constructor calls an addMetadata method when the isForced parameter is true. It seems like it is this "metadata" that is being appended as a suffix to all the log messages.

I don't think that appending a suffix to all the log messages should be the default behavior when using context based log level maps.

Is there a way to turn off the suffix?

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.