This is an automated email from the ASF dual-hosted git repository.

mmerli 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 ae2b8c76cec [improve] Emit flat OpenTelemetry JSON logs instead of ECS 
(#25542)
ae2b8c76cec is described below

commit ae2b8c76cec9dfc240fcbf6ae323f42d0ccbcc28
Author: Matteo Merli <[email protected]>
AuthorDate: Thu Apr 16 12:49:15 2026 -0700

    [improve] Emit flat OpenTelemetry JSON logs instead of ECS (#25542)
---
 bin/bookkeeper              |  2 +-
 bin/pulsar                  |  4 +--
 bin/pulsar-admin-common.cmd |  2 +-
 bin/pulsar-admin-common.sh  |  2 +-
 bin/pulsar-perf             |  2 +-
 conf/OtelLogLayout.json     | 63 +++++++++++++++++++++++++++++++++++++++++++++
 conf/log4j2.yaml            |  2 +-
 conf/pulsar_env.sh          |  2 +-
 8 files changed, 71 insertions(+), 8 deletions(-)

diff --git a/bin/bookkeeper b/bin/bookkeeper
index 2785c0c621c..04d642b45a9 100755
--- a/bin/bookkeeper
+++ b/bin/bookkeeper
@@ -227,7 +227,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 is deprecated — use BOOKIE_LOG_JSON_TEMPLATE
-BOOKIE_LOG_JSON_TEMPLATE=${BOOKIE_LOG_JSON_TEMPLATE:-${BOOKIE_LOG_CONSOLE_JSON_TEMPLATE:-"classpath:EcsLayout.json"}}
+BOOKIE_LOG_JSON_TEMPLATE=${BOOKIE_LOG_JSON_TEMPLATE:-${BOOKIE_LOG_CONSOLE_JSON_TEMPLATE:-"file:$BK_HOME/conf/OtelLogLayout.json"}}
 BOOKIE_LOG_FORMAT=${BOOKIE_LOG_FORMAT:-"text"}
 
 # send bookie shell output to console unconditionally
diff --git a/bin/pulsar b/bin/pulsar
index a10bbcc3019..c7b3e1a4a78 100755
--- a/bin/pulsar
+++ b/bin/pulsar
@@ -330,9 +330,9 @@ fi
 
 PULSAR_LOG_APPENDER=${PULSAR_LOG_APPENDER:-"RoutingAppender"}
 # PULSAR_LOG_CONSOLE_JSON_TEMPLATE is deprecated — use PULSAR_LOG_JSON_TEMPLATE
-PULSAR_LOG_JSON_TEMPLATE=${PULSAR_LOG_JSON_TEMPLATE:-${PULSAR_LOG_CONSOLE_JSON_TEMPLATE:-"classpath:EcsLayout.json"}}
+PULSAR_LOG_JSON_TEMPLATE=${PULSAR_LOG_JSON_TEMPLATE:-${PULSAR_LOG_CONSOLE_JSON_TEMPLATE:-"file:$PULSAR_HOME/conf/OtelLogLayout.json"}}
 PULSAR_ROUTING_APPENDER_DEFAULT=${PULSAR_ROUTING_APPENDER_DEFAULT:-"Console"}
-# Log format: "text" (default) or "json" (ECS JSON) — selects the layout for 
both
+# Log format: "text" (default) or "json" (OpenTelemetry-flat JSON) — selects 
the layout for both
 # the Console and RollingFile appenders via Log4j2 SystemPropertyArbiter
 PULSAR_LOG_FORMAT=${PULSAR_LOG_FORMAT:-"text"}
 
diff --git a/bin/pulsar-admin-common.cmd b/bin/pulsar-admin-common.cmd
index 28e1e3c67cc..063f1100619 100644
--- a/bin/pulsar-admin-common.cmd
+++ b/bin/pulsar-admin-common.cmd
@@ -115,7 +115,7 @@ if "%PULSAR_LOG_DIR%" == "" set 
"PULSAR_LOG_DIR=%PULSAR_HOME%\logs"
 if "%PULSAR_LOG_APPENDER%" == "" set "PULSAR_LOG_APPENDER=RoutingAppender"
 REM PULSAR_LOG_CONSOLE_JSON_TEMPLATE is deprecated -- use 
PULSAR_LOG_JSON_TEMPLATE
 if "%PULSAR_LOG_JSON_TEMPLATE%" == "" set 
"PULSAR_LOG_JSON_TEMPLATE=%PULSAR_LOG_CONSOLE_JSON_TEMPLATE%"
-if "%PULSAR_LOG_JSON_TEMPLATE%" == "" set 
"PULSAR_LOG_JSON_TEMPLATE=classpath:EcsLayout.json"
+if "%PULSAR_LOG_JSON_TEMPLATE%" == "" set 
"PULSAR_LOG_JSON_TEMPLATE=file:%PULSAR_HOME%/conf/OtelLogLayout.json"
 if "%PULSAR_LOG_FORMAT%" == "" set "PULSAR_LOG_FORMAT=text"
 if "%PULSAR_ROUTING_APPENDER_DEFAULT%" == "" set 
"PULSAR_ROUTING_APPENDER_DEFAULT=Console"
 if "%PULSAR_LOG_IMMEDIATE_FLUSH%" == "" set "PULSAR_LOG_IMMEDIATE_FLUSH=false"
diff --git a/bin/pulsar-admin-common.sh b/bin/pulsar-admin-common.sh
index 673534b76f8..47721414066 100755
--- a/bin/pulsar-admin-common.sh
+++ b/bin/pulsar-admin-common.sh
@@ -151,7 +151,7 @@ OPTS="$OPTS $PULSAR_EXTRA_OPTS"
 PULSAR_LOG_DIR=${PULSAR_LOG_DIR:-"$PULSAR_HOME/logs"}
 PULSAR_LOG_APPENDER=${PULSAR_LOG_APPENDER:-"RoutingAppender"}
 # PULSAR_LOG_CONSOLE_JSON_TEMPLATE is deprecated — use PULSAR_LOG_JSON_TEMPLATE
-PULSAR_LOG_JSON_TEMPLATE=${PULSAR_LOG_JSON_TEMPLATE:-${PULSAR_LOG_CONSOLE_JSON_TEMPLATE:-"classpath:EcsLayout.json"}}
+PULSAR_LOG_JSON_TEMPLATE=${PULSAR_LOG_JSON_TEMPLATE:-${PULSAR_LOG_CONSOLE_JSON_TEMPLATE:-"file:$PULSAR_HOME/conf/OtelLogLayout.json"}}
 PULSAR_LOG_FORMAT=${PULSAR_LOG_FORMAT:-"text"}
 PULSAR_LOG_LEVEL=${PULSAR_LOG_LEVEL:-"info"}
 PULSAR_LOG_ROOT_LEVEL=${PULSAR_LOG_ROOT_LEVEL:-"${PULSAR_LOG_LEVEL}"}
diff --git a/bin/pulsar-perf b/bin/pulsar-perf
index 383cac5d6a4..5bc495e8aec 100755
--- a/bin/pulsar-perf
+++ b/bin/pulsar-perf
@@ -146,7 +146,7 @@ OPTS="$OPTS $PULSAR_EXTRA_OPTS"
 # log directory & file
 PULSAR_LOG_APPENDER=${PULSAR_LOG_APPENDER:-"Console"}
 # PULSAR_LOG_CONSOLE_JSON_TEMPLATE is deprecated — use PULSAR_LOG_JSON_TEMPLATE
-PULSAR_LOG_JSON_TEMPLATE=${PULSAR_LOG_JSON_TEMPLATE:-${PULSAR_LOG_CONSOLE_JSON_TEMPLATE:-"classpath:EcsLayout.json"}}
+PULSAR_LOG_JSON_TEMPLATE=${PULSAR_LOG_JSON_TEMPLATE:-${PULSAR_LOG_CONSOLE_JSON_TEMPLATE:-"file:$PULSAR_HOME/conf/OtelLogLayout.json"}}
 PULSAR_LOG_FORMAT=${PULSAR_LOG_FORMAT:-"text"}
 PULSAR_LOG_FILE=${PULSAR_LOG_FILE:-"pulsar-perftest.log"}
 PULSAR_LOG_IMMEDIATE_FLUSH="${PULSAR_LOG_IMMEDIATE_FLUSH:-"false"}"
diff --git a/conf/OtelLogLayout.json b/conf/OtelLogLayout.json
new file mode 100644
index 00000000000..d3e8e95f856
--- /dev/null
+++ b/conf/OtelLogLayout.json
@@ -0,0 +1,63 @@
+{
+  "Timestamp": {
+    "$resolver": "timestamp",
+    "pattern": {
+      "format": "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
+      "timeZone": "UTC"
+    }
+  },
+  "SeverityText": {
+    "$resolver": "level",
+    "field": "name"
+  },
+  "Body": {
+    "$resolver": "message",
+    "stringified": true
+  },
+  "TraceId": {
+    "$resolver": "mdc",
+    "key": "trace_id"
+  },
+  "SpanId": {
+    "$resolver": "mdc",
+    "key": "span_id"
+  },
+  "TraceFlags": {
+    "$resolver": "mdc",
+    "key": "trace_flags"
+  },
+  "Attributes": {
+    "thread.name": {
+      "$resolver": "thread",
+      "field": "name"
+    },
+    "thread.id": {
+      "$resolver": "thread",
+      "field": "id"
+    },
+    "code.namespace": {
+      "$resolver": "logger",
+      "field": "name"
+    },
+    "exception.type": {
+      "$resolver": "exception",
+      "field": "className"
+    },
+    "exception.message": {
+      "$resolver": "exception",
+      "field": "message"
+    },
+    "exception.stacktrace": {
+      "$resolver": "exception",
+      "field": "stackTrace",
+      "stackTrace": {
+        "stringified": true
+      }
+    },
+    "mdc": {
+      "$resolver": "mdc",
+      "flatten": true,
+      "stringified": true
+    }
+  }
+}
diff --git a/conf/log4j2.yaml b/conf/log4j2.yaml
index f3ea2199660..180ea7dc1f6 100644
--- a/conf/log4j2.yaml
+++ b/conf/log4j2.yaml
@@ -43,7 +43,7 @@ Configuration:
       - name: "pulsar.log.format"
         value: "text"
       - name: "pulsar.log.json.template"
-        value: "classpath:EcsLayout.json"
+        value: "file:conf/OtelLogLayout.json"
 
   # Example: logger-filter script
 #  Scripts:
diff --git a/conf/pulsar_env.sh b/conf/pulsar_env.sh
index b84011efd68..7ae9ead07f7 100755
--- a/conf/pulsar_env.sh
+++ b/conf/pulsar_env.sh
@@ -29,7 +29,7 @@
 # Logs location
 # PULSAR_LOG_DIR=
 
-# Log format: "text" (default) or "json" (ECS JSON format, useful for log 
aggregators)
+# Log format: "text" (default) or "json" (flat OpenTelemetry JSON, useful for 
log aggregators)
 # PULSAR_LOG_FORMAT=json
 
 # Configuration file of settings used in broker server

Reply via email to