Skip to content

Commit

Permalink
[Improve][Example] Add log config for job mdc (#7876)
Browse files Browse the repository at this point in the history
  • Loading branch information
hailin0 authored Oct 20, 2024
1 parent b47fca8 commit 266d177
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@

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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
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());
Expand Down

0 comments on commit 266d177

Please sign in to comment.