diff --git a/log4j2/src/main/java/com/google/common/flogger/backend/log4j2/Log4j2SimpleLogEvent.java b/log4j2/src/main/java/com/google/common/flogger/backend/log4j2/Log4j2SimpleLogEvent.java index 4f3d9935..c871b58f 100644 --- a/log4j2/src/main/java/com/google/common/flogger/backend/log4j2/Log4j2SimpleLogEvent.java +++ b/log4j2/src/main/java/com/google/common/flogger/backend/log4j2/Log4j2SimpleLogEvent.java @@ -28,6 +28,7 @@ import org.apache.logging.log4j.core.impl.Log4jLogEvent; import org.apache.logging.log4j.core.util.Throwables; import org.apache.logging.log4j.message.SimpleMessage; +import org.apache.logging.log4j.util.SortedArrayStringMap; /** Class that represents a log entry that can be written to log4j2. */ final class Log4j2SimpleLogEvent implements SimpleLogHandler { @@ -84,9 +85,9 @@ LogEvent asLoggingEvent() { // are written from the current thread. // // Example: - // MDC.put("user.id", userId); + // ThreadContext.put("user.id", userId); // // do business logic that triggers logs - // MDC.clear(); + // ThreadContext.clear(); // // By using '%X{key}' in the ConversionPattern of an appender this data can be included in the // logs. @@ -112,7 +113,7 @@ LogEvent asLoggingEvent() { .setThrown(thrown != null ? Throwables.getRootCause(thrown) : null) .setIncludeLocation(true) .setSource(getLocationInfo()) - .setContextMap(mdcProperties) + .setContextData(new SortedArrayStringMap(mdcProperties)) .build(); }