From 2bb05a0797dc6e632ac073d26b49f6375702abd4 Mon Sep 17 00:00:00 2001 From: Michael Barry Date: Thu, 26 Oct 2023 07:30:56 -0400 Subject: [PATCH] fix log4j log format (#697) --- .../src/main/java/com/onthegomap/planetiler/util/LogUtil.java | 2 +- planetiler-core/src/main/resources/log4j2.properties | 2 +- planetiler-core/src/test/resources/log4j2-test.properties | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/planetiler-core/src/main/java/com/onthegomap/planetiler/util/LogUtil.java b/planetiler-core/src/main/java/com/onthegomap/planetiler/util/LogUtil.java index 67d7619073..9c62403b64 100644 --- a/planetiler-core/src/main/java/com/onthegomap/planetiler/util/LogUtil.java +++ b/planetiler-core/src/main/java/com/onthegomap/planetiler/util/LogUtil.java @@ -14,7 +14,7 @@ private LogUtil() {} /** Prepends {@code [stage]} to all subsequent logs from this thread. */ public static void setStage(String stage) { - MDC.put(STAGE_KEY, stage); + MDC.put(STAGE_KEY, "[%s] ".formatted(stage)); } /** Removes {@code [stage]} from subsequent logs from this thread. */ diff --git a/planetiler-core/src/main/resources/log4j2.properties b/planetiler-core/src/main/resources/log4j2.properties index f99fcf0a30..00e993bb1a 100644 --- a/planetiler-core/src/main/resources/log4j2.properties +++ b/planetiler-core/src/main/resources/log4j2.properties @@ -2,7 +2,7 @@ appenders=console appender.console.type=Console appender.console.name=STDOUT appender.console.layout.type=PatternLayout -appender.console.layout.pattern=%highlight{$${uptime:now} %level{length=3} %notEmpty{[%X{stage}] }- %msg%n%throwable}{FATAL=red, ERROR=red, WARN=YELLOW, INFO=normal, DEBUG=normal, TRACE=normal} +appender.console.layout.pattern=%highlight{$${uptime:now} %level{length=3} %X{stage}- %msg%n%throwable}{FATAL=red, ERROR=red, WARN=YELLOW, INFO=normal, DEBUG=normal, TRACE=normal} packages=com.onthegomap.planetiler.util.log4j rootLogger.level=debug rootLogger.appenderRefs=stdout diff --git a/planetiler-core/src/test/resources/log4j2-test.properties b/planetiler-core/src/test/resources/log4j2-test.properties index f5350b6ce8..3140f703c0 100644 --- a/planetiler-core/src/test/resources/log4j2-test.properties +++ b/planetiler-core/src/test/resources/log4j2-test.properties @@ -2,7 +2,7 @@ appenders=console appender.console.type=Console appender.console.name=STDOUT appender.console.layout.type=PatternLayout -appender.console.layout.pattern=$${uptime:now} %level{length=3} %notEmpty{[%X{stage}] }- %msg%n%throwable +appender.console.layout.pattern=$${uptime:now} %level{length=3} %X{stage}- %msg%n%throwable packages=com.onthegomap.planetiler.util.log4j rootLogger.level=warn rootLogger.appenderRefs=stdout