FrankYang0529 commented on code in PR #18290:
URL: https://github.com/apache/kafka/pull/18290#discussion_r1898913342
##########
bin/kafka-run-class.sh:
##########
@@ -225,6 +225,18 @@ if [ -z "$KAFKA_LOG4J_OPTS" ]; then
(( WINDOWS_OS_FORMAT )) && LOG4J_DIR=$(cygpath --path --mixed "${LOG4J_DIR}")
KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:${LOG4J_DIR}"
else
+ if echo "$KAFKA_LOG4J_OPTS" | grep -qE "log4j\.[^[:space:]]+$"; then
+ # Extract Log4j 1.x configuration file path from KAFKA_LOG4J_OPTS
+ LOG4J1_CONFIG=$(echo "$KAFKA_LOG4J_OPTS" | grep -o
'log4j\.configuration=\S*' | cut -d'=' -f2)
+
+ # Enable Log4j 1.x configuration compatibility mode for Log4j 2
+ export LOG4J_COMPATIBILITY=true
Review Comment:
From document, set one of confituration from `log4j1.compatibility` and
`log4j.configuration` if needing to install log4j1 to log4j2 bridge. It looks
like we can set `LOG4J_COMPATIBILITY=true` only if `LOG4J1_CONFIG` has
properties file. Also, setting `LOG4J_CONFIGURATION_FILE="$LOG4J1_CONFIG"` only
if `LOG4J1_CONFIG` doesn't have properties file.
https://logging.apache.org/log4j/2.x/migrate-from-log4j1.html#ConfigurationCompatibility
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]