Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KAFKA-9366: Change log4j dependency into log4j2 #7898

Closed
wants to merge 9 commits into from
Closed
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Follow instructions in https://kafka.apache.org/quickstart
./gradlew clients:test --tests org.apache.kafka.clients.MetadataTest.testTimeToNextUpdate

### Running a particular unit/integration test with log4j output ###
Change the log4j setting in either `clients/src/test/resources/log4j.properties` or `core/src/test/resources/log4j.properties`
Change the log4j setting in either `clients/src/test/resources/log4j2.properties` or `core/src/test/resources/log4j2.properties`

./gradlew clients:test --tests RequestResponseTest

Expand Down
1 change: 1 addition & 0 deletions bin/connect-distributed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fi
base_dir=$(dirname $0)

if [ "x$KAFKA_LOG4J_OPTS" = "x" ]; then
echo "DEPRECATED: using log4j 1.x configuration. To use log4j 2.x configuration, run with: 'export KAFKA_LOG4J_OPTS=\"-Dlog4j.configurationFile=file:$base_dir/../config/connect-log4j2.properties\"'"
export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:$base_dir/../config/connect-log4j.properties"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you change this (and all the similar cases) to the log4j2 property? If I get it right then after the upgrade -Dlog4j.configuration won't work anyway so while I see the value of notifying the user, I think we should just use the log4j2 property outright. Or is there a backward compatibity, so does log4j.configuration work under log4j2?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if you set log4j.configuration to reference a log4j.xml (Log4j 1 configuration) and you have log4j-1.2-api on the classpath then Log4j 2 will process the log4j 1 configuration. We improve this support with every release. Substantial improvements will be in 2.17.2 which should come out by the end of the month.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rgoers Thanks for the clarification. It seems like we also have to upgrade to log4j 2.17.2 soon.

fi

Expand Down
1 change: 1 addition & 0 deletions bin/connect-mirror-maker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fi
base_dir=$(dirname $0)

if [ "x$KAFKA_LOG4J_OPTS" = "x" ]; then
echo "DEPRECATED: using log4j 1.x configuration. To use log4j 2.x configuration, run with: 'export KAFKA_LOG4J_OPTS=\"-Dlog4j.configurationFile=file:$base_dir/../config/connect-log4j2.properties\"'"
export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:$base_dir/../config/connect-log4j.properties"
fi

Expand Down
1 change: 1 addition & 0 deletions bin/connect-standalone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fi
base_dir=$(dirname $0)

if [ "x$KAFKA_LOG4J_OPTS" = "x" ]; then
echo "DEPRECATED: using log4j 1.x configuration. To use log4j 2.x configuration, run with: 'export KAFKA_LOG4J_OPTS=\"-Dlog4j.configurationFile=file:$base_dir/../config/connect-log4j2.properties\"'"
export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:$base_dir/../config/connect-log4j.properties"
fi

Expand Down
1 change: 1 addition & 0 deletions bin/kafka-server-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ fi
base_dir=$(dirname $0)

if [ "x$KAFKA_LOG4J_OPTS" = "x" ]; then
echo "DEPRECATED: using log4j 1.x configuration. To use log4j 2.x configuration, run with: 'export KAFKA_LOG4J_OPTS=\"-Dlog4j.configurationFile=file:$base_dir/../config/log4j2.properties\"'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the plan to remove this and use the log4j2 file by default in the next major release?

export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:$base_dir/../config/log4j.properties"
fi

Expand Down
1 change: 1 addition & 0 deletions bin/windows/connect-distributed.bat
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ popd

rem Log4j settings
IF ["%KAFKA_LOG4J_OPTS%"] EQU [""] (
echo DEPRECATED: using log4j 1.x configuration. To use log4j 2.x configuration, run with: 'set KAFKA_LOG4J_OPTS=-Dlog4j.configurationFile=file:%BASE_DIR%/config/connect-log4j2.properties'
set KAFKA_LOG4J_OPTS=-Dlog4j.configuration=file:%BASE_DIR%/config/connect-log4j.properties
)

Expand Down
1 change: 1 addition & 0 deletions bin/windows/connect-standalone.bat
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ popd

rem Log4j settings
IF ["%KAFKA_LOG4J_OPTS%"] EQU [""] (
echo DEPRECATED: using log4j 1.x configuration. To use log4j 2.x configuration, run with: 'set KAFKA_LOG4J_OPTS=-Dlog4j.configurationFile=file:%BASE_DIR%/config/connect-log4j2.properties'
set KAFKA_LOG4J_OPTS=-Dlog4j.configuration=file:%BASE_DIR%/config/connect-log4j.properties
)

Expand Down
1 change: 1 addition & 0 deletions bin/windows/kafka-server-start.bat
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ IF [%1] EQU [] (

SetLocal
IF ["%KAFKA_LOG4J_OPTS%"] EQU [""] (
echo DEPRECATED: using log4j 1.x configuration. To use log4j 2.x configuration, run with: 'set KAFKA_LOG4J_OPTS=-Dlog4j.configurationFile=file:%~dp0../../config/log4j2.properties'
set KAFKA_LOG4J_OPTS=-Dlog4j.configuration=file:%~dp0../../config/log4j.properties
)
IF ["%KAFKA_HEAP_OPTS%"] EQU [""] (
Expand Down
3 changes: 3 additions & 0 deletions bin/windows/zookeeper-server-start.bat
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ IF [%1] EQU [] (
EXIT /B 1
)

echo Running with log4j 2.x - Log4j MBean registration is not supported.

SetLocal
IF ["%KAFKA_LOG4J_OPTS%"] EQU [""] (
echo DEPRECATED: using log4j 1.x configuration. To use log4j 2.x configuration, run with: 'set KAFKA_LOG4J_OPTS=-Dlog4j.configurationFile=file:%~dp0../../config/log4j2.properties'
set KAFKA_LOG4J_OPTS=-Dlog4j.configuration=file:%~dp0../../config/log4j.properties
)
IF ["%KAFKA_HEAP_OPTS%"] EQU [""] (
Expand Down
3 changes: 3 additions & 0 deletions bin/zookeeper-server-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ fi
base_dir=$(dirname $0)

if [ "x$KAFKA_LOG4J_OPTS" = "x" ]; then
echo "DEPRECATED: using log4j 1.x configuration. To use log4j 2.x configuration, run with: 'export KAFKA_LOG4J_OPTS=\"-Dlog4j.configurationFile=file:$base_dir/../config/log4j2.properties\"'"
export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:$base_dir/../config/log4j.properties"
fi

echo "Running with log4j 2.x - Log4j MBean registration is not supported."

if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
export KAFKA_HEAP_OPTS="-Xmx512M -Xms512M"
fi
Expand Down
Loading