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

wanghailin pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/seatunnel.git


The following commit(s) were added to refs/heads/dev by this push:
     new 266d1773e5 [Improve][Example] Add log config for job mdc (#7876)
266d1773e5 is described below

commit 266d1773e56dca0484e633060ab3242d8fd2445d
Author: hailin0 <[email protected]>
AuthorDate: Sun Oct 20 21:52:17 2024 +0800

    [Improve][Example] Add log config for job mdc (#7876)
---
 seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.cmd         | 1 +
 seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.sh          | 1 +
 .../org/apache/seatunnel/example/engine/SeaTunnelEngineExample.java | 5 +++++
 .../seatunnel/example/engine/SeaTunnelEngineServerExample.java      | 6 ++++++
 4 files changed, 13 insertions(+)

diff --git a/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.cmd 
b/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.cmd
index cecd3797cd..ef5ead87e3 100644
--- a/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.cmd
+++ b/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.cmd
@@ -66,6 +66,7 @@ REM if you want to debug, please
 REM set "JAVA_OPTS=%JAVA_OPTS% -Xdebug 
-Xrunjdwp:transport=dt_socket,server=y,address=5000,suspend=n"
 
 REM Log4j2 Config
+set "JAVA_OPTS=%JAVA_OPTS% -Dlog4j2.isThreadContextMapInheritable=true"
 if exist "%CONF_DIR%\log4j2_client.properties" (
     set "JAVA_OPTS=%JAVA_OPTS% -Dhazelcast.logging.type=log4j2 
-Dlog4j2.configurationFile=%CONF_DIR%\log4j2_client.properties"
     set "JAVA_OPTS=%JAVA_OPTS% -Dseatunnel.logs.path=%APP_DIR%\logs"
diff --git a/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.sh 
b/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.sh
index dc4c3f91e5..754f2337c6 100755
--- a/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.sh
+++ b/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.sh
@@ -80,6 +80,7 @@ JAVA_OPTS="${JAVA_OPTS} 
-Dhazelcast.config=${HAZELCAST_CONFIG}"
 # JAVA_OPTS="${JAVA_OPTS} -Xdebug 
-Xrunjdwp:transport=dt_socket,server=y,address=5000,suspend=n"
 
 # Log4j2 Config
+JAVA_OPTS="${JAVA_OPTS} -Dlog4j2.isThreadContextMapInheritable=true"
 if [ -e "${CONF_DIR}/log4j2_client.properties" ]; then
   JAVA_OPTS="${JAVA_OPTS} -Dhazelcast.logging.type=log4j2 
-Dlog4j2.configurationFile=${CONF_DIR}/log4j2_client.properties"
   JAVA_OPTS="${JAVA_OPTS} -Dseatunnel.logs.path=${APP_DIR}/logs"
diff --git 
a/seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineExample.java
 
b/seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineExample.java
index 2a7c25e083..26a965fefb 100644
--- 
a/seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineExample.java
+++ 
b/seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineExample.java
@@ -29,6 +29,11 @@ import java.nio.file.Paths;
 
 public class SeaTunnelEngineExample {
 
+    static {
+        // 
https://logging.apache.org/log4j/2.x/manual/simple-logger.html#isThreadContextMapInheritable
+        System.setProperty("log4j2.isThreadContextMapInheritable", "true");
+    }
+
     public static void main(String[] args)
             throws FileNotFoundException, URISyntaxException, CommandException 
{
         String configurePath = args.length > 0 ? args[0] : 
"/examples/fake_to_console.conf";
diff --git 
a/seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineServerExample.java
 
b/seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineServerExample.java
index df539ea6e0..07b363c41d 100644
--- 
a/seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineServerExample.java
+++ 
b/seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineServerExample.java
@@ -22,6 +22,12 @@ import 
org.apache.seatunnel.core.starter.exception.CommandException;
 import org.apache.seatunnel.core.starter.seatunnel.args.ServerCommandArgs;
 
 public class SeaTunnelEngineServerExample {
+
+    static {
+        // 
https://logging.apache.org/log4j/2.x/manual/simple-logger.html#isThreadContextMapInheritable
+        System.setProperty("log4j2.isThreadContextMapInheritable", "true");
+    }
+
     public static void main(String[] args) throws CommandException {
         ServerCommandArgs serverCommandArgs = new ServerCommandArgs();
         SeaTunnel.run(serverCommandArgs.buildCommand());

Reply via email to