This is an automated email from the ASF dual-hosted git repository.
lhotari pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new 2c840ba0c82 [improve][misc]introduce log4j Console appender
ConsoleJson (#25034)
2c840ba0c82 is described below
commit 2c840ba0c82edf1b8af5668c5629b356b545d576
Author: Simon Beeli <[email protected]>
AuthorDate: Thu Dec 4 13:43:02 2025 +0100
[improve][misc]introduce log4j Console appender ConsoleJson (#25034)
---
bin/bookkeeper | 2 ++
bin/pulsar | 2 ++
bin/pulsar-admin-common.cmd | 2 ++
bin/pulsar-admin-common.sh | 2 ++
bin/pulsar-perf | 2 ++
conf/log4j2.yaml | 14 ++++++++++----
src/pulsar-io-gen.sh | 2 ++
7 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/bin/bookkeeper b/bin/bookkeeper
index 59369c8087e..b61123e3c85 100755
--- a/bin/bookkeeper
+++ b/bin/bookkeeper
@@ -214,6 +214,7 @@ OPTS="$OPTS $BOOKIE_MEM $BOOKIE_GC $BOOKIE_GC_LOG
$BOOKIE_EXTRA_OPTS"
# log directory & file
BOOKIE_LOG_APPENDER=${BOOKIE_LOG_APPENDER:-"Console"}
+BOOKIE_LOG_CONSOLE_JSON_TEMPLATE=${BOOKIE_LOG_CONSOLE_JSON_TEMPLATE:-"classpath:EcsLayout.json"}
# send bookie shell output to console unconditionally
if [ $COMMAND == "shell" ]; then
@@ -227,6 +228,7 @@ fi
#Configure log configuration system properties
OPTS="$OPTS -Dpulsar.log.appender=$BOOKIE_LOG_APPENDER"
+OPTS="$OPTS
-Dpulsar.log.console.json.template=$BOOKIE_LOG_CONSOLE_JSON_TEMPLATE"
OPTS="$OPTS -Dbk.log.appender=$BOOKIE_LOG_APPENDER"
OPTS="$OPTS -Dbk.log.level=error"
OPTS="$OPTS -Dpulsar.log.dir=$BOOKIE_LOG_DIR"
diff --git a/bin/pulsar b/bin/pulsar
index 605f9df41b0..b879019eb18 100755
--- a/bin/pulsar
+++ b/bin/pulsar
@@ -311,6 +311,7 @@ else
fi
PULSAR_LOG_APPENDER=${PULSAR_LOG_APPENDER:-"RoutingAppender"}
+PULSAR_LOG_CONSOLE_JSON_TEMPLATE=${PULSAR_LOG_CONSOLE_JSON_TEMPLATE:-"classpath:EcsLayout.json"}
PULSAR_ROUTING_APPENDER_DEFAULT=${PULSAR_ROUTING_APPENDER_DEFAULT:-"Console"}
if [ ! -d "$PULSAR_LOG_DIR" ]; then
mkdir -p "$PULSAR_LOG_DIR"
@@ -319,6 +320,7 @@
PULSAR_LOG_IMMEDIATE_FLUSH="${PULSAR_LOG_IMMEDIATE_FLUSH:-"false"}"
#Configure log configuration system properties
OPTS="$OPTS -Dpulsar.log.appender=$PULSAR_LOG_APPENDER"
+OPTS="$OPTS
-Dpulsar.log.console.json.template=$PULSAR_LOG_CONSOLE_JSON_TEMPLATE"
OPTS="$OPTS -Dpulsar.log.dir=$PULSAR_LOG_DIR"
if [ -n "$PULSAR_LOG_LEVEL" ]; then
OPTS="$OPTS -Dpulsar.log.level=$PULSAR_LOG_LEVEL"
diff --git a/bin/pulsar-admin-common.cmd b/bin/pulsar-admin-common.cmd
index 0e46cd3dead..e3f4754ea55 100644
--- a/bin/pulsar-admin-common.cmd
+++ b/bin/pulsar-admin-common.cmd
@@ -89,10 +89,12 @@ set "OPTS=%OPTS% %PULSAR_EXTRA_OPTS%"
if "%PULSAR_LOG_DIR%" == "" set "PULSAR_LOG_DIR=%PULSAR_HOME%\logs"
if "%PULSAR_LOG_APPENDER%" == "" set "PULSAR_LOG_APPENDER=RoutingAppender"
+if "%PULSAR_LOG_CONSOLE_JSON_TEMPLATE%" == "" set
"PULSAR_LOG_CONSOLE_JSON_TEMPLATE=classpath:EcsLayout.json"
if "%PULSAR_ROUTING_APPENDER_DEFAULT%" == "" set
"PULSAR_ROUTING_APPENDER_DEFAULT=Console"
if "%PULSAR_LOG_IMMEDIATE_FLUSH%" == "" set "PULSAR_LOG_IMMEDIATE_FLUSH=false"
set "OPTS=%OPTS% -Dpulsar.log.appender=%PULSAR_LOG_APPENDER%"
+set "OPTS=%OPTS%
-Dpulsar.log.console.json.template=%PULSAR_LOG_CONSOLE_JSON_TEMPLATE%"
set "OPTS=%OPTS% -Dpulsar.log.dir=%PULSAR_LOG_DIR%"
if not "%PULSAR_LOG_LEVEL%" == "" set "OPTS=%OPTS%
-Dpulsar.log.level=%PULSAR_LOG_LEVEL%"
if not "%PULSAR_LOG_ROOT_LEVEL%" == "" (
diff --git a/bin/pulsar-admin-common.sh b/bin/pulsar-admin-common.sh
index cedf8707627..366d76d7f5b 100755
--- a/bin/pulsar-admin-common.sh
+++ b/bin/pulsar-admin-common.sh
@@ -134,6 +134,7 @@ OPTS="$OPTS $PULSAR_EXTRA_OPTS"
# log directory & file
PULSAR_LOG_DIR=${PULSAR_LOG_DIR:-"$PULSAR_HOME/logs"}
PULSAR_LOG_APPENDER=${PULSAR_LOG_APPENDER:-"RoutingAppender"}
+PULSAR_LOG_CONSOLE_JSON_TEMPLATE=${PULSAR_LOG_CONSOLE_JSON_TEMPLATE:-"classpath:EcsLayout.json"}
PULSAR_LOG_LEVEL=${PULSAR_LOG_LEVEL:-"info"}
PULSAR_LOG_ROOT_LEVEL=${PULSAR_LOG_ROOT_LEVEL:-"${PULSAR_LOG_LEVEL}"}
PULSAR_ROUTING_APPENDER_DEFAULT=${PULSAR_ROUTING_APPENDER_DEFAULT:-"Console"}
@@ -141,6 +142,7 @@
PULSAR_LOG_IMMEDIATE_FLUSH="${PULSAR_LOG_IMMEDIATE_FLUSH:-"false"}"
#Configure log configuration system properties
OPTS="$OPTS -Dpulsar.log.appender=$PULSAR_LOG_APPENDER"
+OPTS="$OPTS
-Dpulsar.log.console.json.template=$PULSAR_LOG_CONSOLE_JSON_TEMPLATE"
OPTS="$OPTS -Dpulsar.log.dir=$PULSAR_LOG_DIR"
OPTS="$OPTS -Dpulsar.log.level=$PULSAR_LOG_LEVEL"
OPTS="$OPTS -Dpulsar.log.root.level=$PULSAR_LOG_ROOT_LEVEL"
diff --git a/bin/pulsar-perf b/bin/pulsar-perf
index dc1bdfa2d28..2b120cc2f94 100755
--- a/bin/pulsar-perf
+++ b/bin/pulsar-perf
@@ -129,11 +129,13 @@ OPTS="$OPTS $PULSAR_EXTRA_OPTS"
# log directory & file
PULSAR_LOG_APPENDER=${PULSAR_LOG_APPENDER:-"Console"}
+PULSAR_LOG_CONSOLE_JSON_TEMPLATE=${PULSAR_LOG_CONSOLE_JSON_TEMPLATE:-"classpath:EcsLayout.json"}
PULSAR_LOG_FILE=${PULSAR_LOG_FILE:-"pulsar-perftest.log"}
PULSAR_LOG_IMMEDIATE_FLUSH="${PULSAR_LOG_IMMEDIATE_FLUSH:-"false"}"
#Configure log configuration system properties
OPTS="$OPTS -Dpulsar.log.appender=$PULSAR_LOG_APPENDER"
+OPTS="$OPTS
-Dpulsar.log.console.json.template=$PULSAR_LOG_CONSOLE_JSON_TEMPLATE"
if [ -n "$PULSAR_LOG_LEVEL" ]; then
OPTS="$OPTS -Dpulsar.log.level=$PULSAR_LOG_LEVEL"
fi
diff --git a/conf/log4j2.yaml b/conf/log4j2.yaml
index 0e49503581c..2571c2d9ab9 100644
--- a/conf/log4j2.yaml
+++ b/conf/log4j2.yaml
@@ -40,6 +40,8 @@ Configuration:
value: "info"
- name: "pulsar.routing.appender.default"
value: "Console"
+ - name: "pulsar.log.console.json.template"
+ value: "classpath:EcsLayout.json"
# Example: logger-filter script
# Scripts:
@@ -53,10 +55,14 @@ Configuration:
# Console
Console:
- name: Console
- target: SYSTEM_OUT
- PatternLayout:
- Pattern: "%d{ISO8601_OFFSET_DATE_TIME_HHMM} [%t] %-5level %logger{36}
- %msg%n"
+ - name: Console
+ target: SYSTEM_OUT
+ PatternLayout:
+ Pattern: "%d{ISO8601_OFFSET_DATE_TIME_HHMM} [%t] %-5level
%logger{36} - %msg%n"
+ - name: ConsoleJson
+ target: SYSTEM_OUT
+ JsonTemplateLayout:
+ eventTemplateUri: ${sys:pulsar.log.console.json.template}
# Rolling file appender configuration
RollingFile:
diff --git a/src/pulsar-io-gen.sh b/src/pulsar-io-gen.sh
index aba1da0d6f8..2748d8b13c4 100755
--- a/src/pulsar-io-gen.sh
+++ b/src/pulsar-io-gen.sh
@@ -120,11 +120,13 @@ OPTS="$OPTS $PULSAR_EXTRA_OPTS"
# log directory & file
PULSAR_LOG_APPENDER=${PULSAR_LOG_APPENDER:-"Console"}
+PULSAR_LOG_CONSOLE_JSON_TEMPLATE=${PULSAR_LOG_CONSOLE_JSON_TEMPLATE:-"classpath:EcsLayout.json"}
PULSAR_LOG_DIR=${PULSAR_LOG_DIR:-"$PULSAR_HOME/logs"}
PULSAR_LOG_FILE=${PULSAR_LOG_FILE:-"pulsar-perftest.log"}
#Configure log configuration system properties
OPTS="$OPTS -Dpulsar.log.appender=$PULSAR_LOG_APPENDER"
+OPTS="$OPTS
-Dpulsar.log.console.json.template=$PULSAR_LOG_CONSOLE_JSON_TEMPLATE"
OPTS="$OPTS -Dpulsar.log.dir=$PULSAR_LOG_DIR"
OPTS="$OPTS -Dpulsar.log.file=$PULSAR_LOG_FILE"