google / flogger

A Fluent Logging API for Java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unexpected suffix in log messages

paulgeiger-eng opened this issue · comments

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?