From f0988ddf250440813866849cef4f734174a48fc4 Mon Sep 17 00:00:00 2001 From: ZhangJian He Date: Sat, 23 Apr 2022 00:10:18 +0800 Subject: [PATCH] Remove log4j from bookkeeper (#3225) --- bin/bkctl | 7 +- bin/bkperf | 7 +- bin/bookkeeper | 7 +- bin/bookkeeper-daemon.sh | 6 +- bin/bookkeeper_gradle | 7 +- bin/common.sh | 30 ++++---- bin/common_gradle.sh | 30 ++++---- bin/dlog | 14 ++-- bookkeeper-benchmark/bin/benchmark | 6 +- bookkeeper-benchmark/build.gradle | 1 - bookkeeper-benchmark/conf/log4j.properties | 69 ----------------- bookkeeper-benchmark/conf/log4j2.xml | 44 +++++++++++ bookkeeper-common/pom.xml | 12 --- bookkeeper-dist/all/build.gradle | 1 - bookkeeper-dist/all/pom.xml | 14 ---- bookkeeper-dist/bkctl/build.gradle | 4 +- bookkeeper-dist/bkctl/pom.xml | 14 ---- bookkeeper-dist/server/build.gradle | 1 - bookkeeper-dist/server/pom.xml | 14 ---- bookkeeper-dist/src/assemble/bkctl.xml | 4 +- .../src/main/resources/LICENSE-all.bin.txt | 1 - .../src/main/resources/LICENSE-bkctl.bin.txt | 1 - .../src/main/resources/LICENSE-server.bin.txt | 1 - bookkeeper-server/pom.xml | 12 --- .../src/main/resources/log4j.properties | 38 --------- .../src/main/resources/log4j2.xml | 33 ++++++++ .../src/main/resources/log4j.properties | 42 ---------- buildtools/src/main/resources/log4j2.xml | 36 +++++++++ conf/bk_cli_env.sh | 3 +- conf/bkenv.sh | 3 +- conf/log4j.cli.properties | 62 --------------- conf/log4j.properties | 77 ------------------- conf/log4j.shell.properties | 45 ----------- conf/log4j2.cli.xml | 53 +++++++++++++ conf/log4j2.shell.xml | 43 +++++++++++ conf/log4j2.xml | 49 ++++++++++++ dependencies.gradle | 1 - dev/stats-doc-gen | 7 +- docker/README.md | 2 +- microbenchmarks/pom.xml | 12 --- pom.xml | 25 +++--- site/_data/cli/bookkeeper.yaml | 2 +- site/docs/latest/admin/bookies.md | 4 +- site3/website/docs/reference/cli.md | 16 ++-- stream/bin/streamstorage | 11 ++- stream/bin/streamstorage-cli | 10 ++- stream/conf/log4j.cli.properties | 73 ------------------ stream/conf/log4j.properties | 73 ------------------ stream/conf/log4j2.cli.xml | 49 ++++++++++++ stream/conf/log4j2.xml | 49 ++++++++++++ stream/server/build.gradle | 1 - .../docker-images/statestore-image/bin/bkctl | 7 +- .../docker-images/statestore-image/bin/bkperf | 7 +- .../statestore-image/bin/bookkeeper | 7 +- .../conf/log4j.cli.properties | 41 ---------- .../statestore-image/conf/log4j.properties | 40 ---------- .../conf/log4j.shell.properties | 41 ---------- .../statestore-image/conf/log4j2.cli.xml | 33 ++++++++ .../statestore-image/conf/log4j2.shell.xml | 33 ++++++++ .../statestore-image/conf/log4j2.xml | 33 ++++++++ tests/integration/cluster/build.gradle | 1 - .../src/test/bash/bk_test_bin_common.sh | 14 ++-- .../test/bash/gradle/bk_test_bin_common.sh | 11 +-- tools/ledger/pom.xml | 5 -- tools/perf/build.gradle | 1 - tools/stream/build.gradle | 1 - 66 files changed, 592 insertions(+), 809 deletions(-) delete mode 100644 bookkeeper-benchmark/conf/log4j.properties create mode 100644 bookkeeper-benchmark/conf/log4j2.xml delete mode 100644 bookkeeper-server/src/main/resources/log4j.properties create mode 100644 bookkeeper-server/src/main/resources/log4j2.xml delete mode 100644 buildtools/src/main/resources/log4j.properties create mode 100644 buildtools/src/main/resources/log4j2.xml delete mode 100644 conf/log4j.cli.properties delete mode 100644 conf/log4j.properties delete mode 100644 conf/log4j.shell.properties create mode 100644 conf/log4j2.cli.xml create mode 100644 conf/log4j2.shell.xml create mode 100644 conf/log4j2.xml delete mode 100644 stream/conf/log4j.cli.properties delete mode 100644 stream/conf/log4j.properties create mode 100644 stream/conf/log4j2.cli.xml create mode 100644 stream/conf/log4j2.xml delete mode 100644 tests/docker-images/statestore-image/conf/log4j.cli.properties delete mode 100644 tests/docker-images/statestore-image/conf/log4j.properties delete mode 100644 tests/docker-images/statestore-image/conf/log4j.shell.properties create mode 100644 tests/docker-images/statestore-image/conf/log4j2.cli.xml create mode 100644 tests/docker-images/statestore-image/conf/log4j2.shell.xml create mode 100644 tests/docker-images/statestore-image/conf/log4j2.xml diff --git a/bin/bkctl b/bin/bkctl index ec0a0c7e71f..26d3b6ececa 100755 --- a/bin/bkctl +++ b/bin/bkctl @@ -42,13 +42,14 @@ if [ -z "${CLI_CONF}" ]; then CLI_CONF=${DEFAULT_CONF} fi -DEFAULT_LOG_CONF=${BK_HOME}/conf/log4j.cli.properties +DEFAULT_LOG_CONF=${BK_HOME}/conf/log4j2.cli.xml if [ -z "${CLI_LOG_CONF}" ]; then CLI_LOG_CONF=${DEFAULT_LOG_CONF} fi CLI_LOG_DIR=${CLI_LOG_DIR:-"$BK_HOME/logs"} CLI_LOG_FILE=${CLI_LOG_FILE:-"bkctl.log"} -CLI_ROOT_LOGGER=${CLI_ROOT_LOGGER:-"INFO,CONSOLE"} +CLI_ROOT_LOG_LEVEL=${CLI_ROOT_LOG_LEVEL:-"INFO"} +CLI_ROOT_LOG_APPENDER=${CLI_ROOT_LOG_APPENDER:-"CONSOLE"} # Configure the classpath CLI_CLASSPATH="$CLI_JAR:$CLI_CLASSPATH:$CLI_EXTRA_CLASSPATH" @@ -58,7 +59,7 @@ CLI_CLASSPATH="`dirname $CLI_LOG_CONF`:$CLI_CLASSPATH" BOOKIE_OPTS=$(build_bookie_opts) GC_OPTS=$(build_cli_jvm_opts ${CLI_LOG_DIR} "bkctl-gc.log") NETTY_OPTS=$(build_netty_opts) -LOGGING_OPTS=$(build_cli_logging_opts ${CLI_LOG_CONF} ${CLI_LOG_DIR} ${CLI_LOG_FILE} ${CLI_ROOT_LOGGER}) +LOGGING_OPTS=$(build_cli_logging_opts ${CLI_LOG_CONF} ${CLI_ROOT_LOG_LEVEL} ${CLI_ROOT_LOG_APPENDER} ${CLI_LOG_DIR} ${CLI_LOG_FILE}) OPTS="${OPTS} -cp ${CLI_CLASSPATH} ${BOOKIE_OPTS} ${GC_OPTS} ${NETTY_OPTS} ${LOGGING_OPTS} ${CLI_EXTRA_OPTS}" diff --git a/bin/bkperf b/bin/bkperf index 857eda4d5fd..1cd3f71fce0 100755 --- a/bin/bkperf +++ b/bin/bkperf @@ -41,13 +41,14 @@ if [ -z "${CLI_CONF}" ]; then CLI_CONF=${DEFAULT_CONF} fi -DEFAULT_LOG_CONF=${BK_HOME}/conf/log4j.cli.properties +DEFAULT_LOG_CONF=${BK_HOME}/conf/log4j2.cli.xml if [ -z "${CLI_LOG_CONF}" ]; then CLI_LOG_CONF=${DEFAULT_LOG_CONF} fi CLI_LOG_DIR=${CLI_LOG_DIR:-"$BK_HOME/logs"} CLI_LOG_FILE=${CLI_LOG_FILE:-"bkperf.log"} -CLI_ROOT_LOGGER=${CLI_ROOT_LOGGER:-"INFO,CONSOLE"} +CLI_ROOT_LOG_LEVEL=${CLI_ROOT_LOG_LEVEL:-"INFO"} +CLI_ROOT_LOG_APPENDER=${CLI_ROOT_LOG_APPENDER:-"CONSOLE"} # Configure the classpath CLI_CLASSPATH="$CLI_JAR:$CLI_CLASSPATH:$CLI_EXTRA_CLASSPATH" @@ -57,7 +58,7 @@ CLI_CLASSPATH="`dirname $CLI_LOG_CONF`:$CLI_CLASSPATH" BOOKIE_OPTS=$(build_bookie_opts) GC_OPTS=$(build_cli_jvm_opts ${CLI_LOG_DIR} "bkperf-gc.log") NETTY_OPTS=$(build_netty_opts) -LOGGING_OPTS=$(build_cli_logging_opts ${CLI_LOG_CONF} ${CLI_LOG_DIR} ${CLI_LOG_FILE} ${CLI_ROOT_LOGGER}) +LOGGING_OPTS=$(build_cli_logging_opts ${CLI_LOG_CONF} ${CLI_ROOT_LOG_LEVEL} ${CLI_ROOT_LOG_APPENDER} ${CLI_LOG_DIR} ${CLI_LOG_FILE}) OPTS="${OPTS} -cp ${CLI_CLASSPATH} ${BOOKIE_OPTS} ${GC_OPTS} ${NETTY_OPTS} ${LOGGING_OPTS} ${CLI_EXTRA_OPTS}" diff --git a/bin/bookkeeper b/bin/bookkeeper index ac409684ff5..cffc267cc72 100755 --- a/bin/bookkeeper +++ b/bin/bookkeeper @@ -107,7 +107,7 @@ shift LOCALBOOKIES_CONFIG_DIR="${LOCALBOOKIES_CONFIG_DIR:-/tmp/localbookies-config}" if [ ${COMMAND} == "shell" ]; then - DEFAULT_LOG_CONF=${BK_HOME}/conf/log4j.shell.properties + DEFAULT_LOG_CONF=${BK_HOME}/conf/log4j2.shell.xml if [[ $1 == "-localbookie" ]]; then if [[ $2 == *:* ]]; then @@ -134,7 +134,8 @@ if [ -z "$BOOKIE_LOG_CONF" ]; then fi BOOKIE_LOG_DIR=${BOOKIE_LOG_DIR:-"$BK_HOME/logs"} BOOKIE_LOG_FILE=${BOOKIE_LOG_FILE:-"bookkeeper-server.log"} -BOOKIE_ROOT_LOGGER=${BOOKIE_ROOT_LOGGER:-"INFO,CONSOLE"} +BOOKIE_ROOT_LOG_LEVEL=${BOOKIE_ROOT_LOG_LEVEL:-"INFO"} +BOOKIE_ROOT_LOG_APPENDER=${BOOKIE_ROOT_LOG_APPENDER:-"CONSOLE"} # Configure the classpath BOOKIE_CLASSPATH="$BOOKIE_JAR:$BOOKIE_CLASSPATH:$BOOKIE_EXTRA_CLASSPATH" @@ -144,7 +145,7 @@ BOOKIE_CLASSPATH="`dirname $BOOKIE_LOG_CONF`:$BOOKIE_CLASSPATH" BOOKIE_OPTS=$(build_bookie_opts) GC_OPTS=$(build_bookie_jvm_opts ${BOOKIE_LOG_DIR} "gc_%p.log") NETTY_OPTS=$(build_netty_opts) -LOGGING_OPTS=$(build_logging_opts ${BOOKIE_LOG_CONF} ${BOOKIE_LOG_DIR} ${BOOKIE_LOG_FILE} ${BOOKIE_ROOT_LOGGER}) +LOGGING_OPTS=$(build_logging_opts ${BOOKIE_LOG_CONF} ${BOOKIE_ROOT_LOG_LEVEL} ${BOOKIE_ROOT_LOG_APPENDER} ${BOOKIE_LOG_DIR} ${BOOKIE_LOG_FILE}) BOOKIE_EXTRA_OPTS="${BOOKIE_EXTRA_OPTS} -Dorg.bouncycastle.fips.approved_only=true" OPTS="${OPTS} -cp ${BOOKIE_CLASSPATH} ${BOOKIE_OPTS} ${GC_OPTS} ${NETTY_OPTS} ${LOGGING_OPTS} ${BOOKIE_EXTRA_OPTS}" diff --git a/bin/bookkeeper-daemon.sh b/bin/bookkeeper-daemon.sh index d64a4489bc1..621aa18e6a8 100755 --- a/bin/bookkeeper-daemon.sh +++ b/bin/bookkeeper-daemon.sh @@ -41,7 +41,8 @@ fi BOOKIE_LOG_DIR=${BOOKIE_LOG_DIR:-"$BK_HOME/logs"} -BOOKIE_ROOT_LOGGER=${BOOKIE_ROOT_LOGGER:-'INFO,ROLLINGFILE'} +BOOKIE_ROOT_LOG_LEVEL=${BOOKIE_ROOT_LOG_LEVEL:-'INFO'} +BOOKIE_ROOT_LOG_APPENDER=${BOOKIE_ROOT_LOG_APPENDER:-'ROLLINGFILE'} BOOKIE_STOP_TIMEOUT=${BOOKIE_STOP_TIMEOUT:-30} @@ -80,7 +81,8 @@ case $command in esac export BOOKIE_LOG_DIR=$BOOKIE_LOG_DIR -export BOOKIE_ROOT_LOGGER=$BOOKIE_ROOT_LOGGER +export BOOKIE_ROOT_LOG_LEVEL=$BOOKIE_ROOT_LOG_LEVEL +export BOOKIE_ROOT_LOG_APPENDER=$BOOKIE_ROOT_LOG_APPENDER export BOOKIE_LOG_FILE=bookkeeper-$command-$HOSTNAME.log pid_file="${BOOKIE_PID_DIR}/bookkeeper-${command}.pid" diff --git a/bin/bookkeeper_gradle b/bin/bookkeeper_gradle index 22545b29cbc..494907a1e67 100755 --- a/bin/bookkeeper_gradle +++ b/bin/bookkeeper_gradle @@ -107,7 +107,7 @@ shift LOCALBOOKIES_CONFIG_DIR="${LOCALBOOKIES_CONFIG_DIR:-/tmp/localbookies-config}" if [ ${COMMAND} == "shell" ]; then - DEFAULT_LOG_CONF=${BK_HOME}/conf/log4j.shell.properties + DEFAULT_LOG_CONF=${BK_HOME}/conf/log4j2.shell.xml if [[ $1 == "-localbookie" ]]; then if [[ $2 == *:* ]]; then @@ -134,7 +134,8 @@ if [ -z "$BOOKIE_LOG_CONF" ]; then fi BOOKIE_LOG_DIR=${BOOKIE_LOG_DIR:-"$BK_HOME/logs"} BOOKIE_LOG_FILE=${BOOKIE_LOG_FILE:-"bookkeeper-server.log"} -BOOKIE_ROOT_LOGGER=${BOOKIE_ROOT_LOGGER:-"INFO,CONSOLE"} +BOOKIE_ROOT_LOG_LEVEL=${BOOKIE_ROOT_LOG_LEVEL:-"INFO"} +BOOKIE_ROOT_LOG_APPENDER=${BOOKIE_ROOT_LOG_APPENDER:-"CONSOLE"} # Configure the classpath BOOKIE_CLASSPATH="$BOOKIE_JAR:$BOOKIE_CLASSPATH:$BOOKIE_EXTRA_CLASSPATH" @@ -144,7 +145,7 @@ BOOKIE_CLASSPATH="`dirname $BOOKIE_LOG_CONF`:$BOOKIE_CLASSPATH" BOOKIE_OPTS=$(build_bookie_opts) GC_OPTS=$(build_bookie_jvm_opts ${BOOKIE_LOG_DIR} "gc_%p.log") NETTY_OPTS=$(build_netty_opts) -LOGGING_OPTS=$(build_logging_opts ${BOOKIE_LOG_CONF} ${BOOKIE_LOG_DIR} ${BOOKIE_LOG_FILE} ${BOOKIE_ROOT_LOGGER}) +LOGGING_OPTS=$(build_logging_opts ${BOOKIE_LOG_CONF} ${BOOKIE_ROOT_LOG_LEVEL} ${BOOKIE_ROOT_LOG_APPENDER} ${BOOKIE_LOG_DIR} ${BOOKIE_LOG_FILE}) BOOKIE_EXTRA_OPTS="${BOOKIE_EXTRA_OPTS} -Dorg.bouncycastle.fips.approved_only=true" OPTS="${OPTS} -cp ${BOOKIE_CLASSPATH} ${BOOKIE_OPTS} ${GC_OPTS} ${NETTY_OPTS} ${LOGGING_OPTS} ${BOOKIE_EXTRA_OPTS}" diff --git a/bin/common.sh b/bin/common.sh index 7949cf9066a..c791ef8b8ae 100755 --- a/bin/common.sh +++ b/bin/common.sh @@ -64,7 +64,7 @@ fi BINDIR=${BK_BINDIR:-"`dirname "$0"`"} BK_HOME=${BK_HOME:-"`cd ${BINDIR}/..;pwd`"} BK_CONFDIR=${BK_HOME}/conf -DEFAULT_LOG_CONF=${BK_CONFDIR}/log4j.properties +DEFAULT_LOG_CONF=${BK_CONFDIR}/log4j2.xml source ${BK_CONFDIR}/nettyenv.sh source ${BK_CONFDIR}/bkenv.sh @@ -289,24 +289,28 @@ build_netty_opts() { build_logging_opts() { CONF_FILE=$1 - LOG_DIR=$2 - LOG_FILE=$3 - LOGGER=$4 - - echo "-Dlog4j.configuration=`basename ${CONF_FILE}` \ - -Dbookkeeper.root.logger=${LOGGER} \ + LOG_LEVEL=$2 + LOG_APPENDER=$3 + LOG_DIR=$4 + LOG_FILE=$5 + + echo "-Dlog4j.configurationFile=`basename ${CONF_FILE}` \ + -Dbookkeeper.log.root.level=${LOG_LEVEL} \ + -Dbookkeeper.log.root.appender=${LOG_APPENDER} \ -Dbookkeeper.log.dir=${LOG_DIR} \ -Dbookkeeper.log.file=${LOG_FILE}" } build_cli_logging_opts() { CONF_FILE=$1 - LOG_DIR=$2 - LOG_FILE=$3 - LOGGER=$4 - - echo "-Dlog4j.configuration=`basename ${CONF_FILE}` \ - -Dbookkeeper.cli.root.logger=${LOGGER} \ + LOG_LEVEL=$2 + LOG_APPENDER=$3 + LOG_DIR=$4 + LOG_FILE=$5 + + echo "-Dlog4j.configurationFile=`basename ${CONF_FILE}` \ + -Dbookkeeper.cli.log.root.level=${LOG_LEVEL} \ + -Dbookkeeper.cli.log.root.appender=${LOG_APPENDER} \ -Dbookkeeper.cli.log.dir=${LOG_DIR} \ -Dbookkeeper.cli.log.file=${LOG_FILE}" } diff --git a/bin/common_gradle.sh b/bin/common_gradle.sh index 82d8fdb8773..99ac6124150 100755 --- a/bin/common_gradle.sh +++ b/bin/common_gradle.sh @@ -64,7 +64,7 @@ fi BINDIR=${BK_BINDIR:-"`dirname "$0"`"} BK_HOME=${BK_HOME:-"`cd ${BINDIR}/..;pwd`"} BK_CONFDIR=${BK_HOME}/conf -DEFAULT_LOG_CONF=${BK_CONFDIR}/log4j.properties +DEFAULT_LOG_CONF=${BK_CONFDIR}/log4j2.xml source ${BK_CONFDIR}/nettyenv.sh source ${BK_CONFDIR}/bkenv.sh @@ -271,24 +271,28 @@ build_netty_opts() { build_logging_opts() { CONF_FILE=$1 - LOG_DIR=$2 - LOG_FILE=$3 - LOGGER=$4 - - echo "-Dlog4j.configuration=`basename ${CONF_FILE}` \ - -Dbookkeeper.root.logger=${LOGGER} \ + LOG_LEVEL=$2 + LOG_APPENDER=$3 + LOG_DIR=$4 + LOG_FILE=$5 + + echo "-Dlog4j.configurationFile=`basename ${CONF_FILE}` \ + -Dbookkeeper.log.root.level=${LOG_LEVEL} \ + -Dbookkeeper.log.root.appender=${LOG_APPENDER} \ -Dbookkeeper.log.dir=${LOG_DIR} \ -Dbookkeeper.log.file=${LOG_FILE}" } build_cli_logging_opts() { CONF_FILE=$1 - LOG_DIR=$2 - LOG_FILE=$3 - LOGGER=$4 - - echo "-Dlog4j.configuration=`basename ${CONF_FILE}` \ - -Dbookkeeper.cli.root.logger=${LOGGER} \ + LOG_LEVEL=$2 + LOG_APPENDER=$3 + LOG_DIR=$4 + LOG_FILE=$5 + + echo "-Dlog4j.configurationFile=`basename ${CONF_FILE}` \ + -Dbookkeeper.cli.log.root.level=${LOG_LEVEL} \ + -Dbookkeeper.cli.log.root.appender=${LOG_APPENDER} \ -Dbookkeeper.cli.log.dir=${LOG_DIR} \ -Dbookkeeper.cli.log.file=${LOG_FILE}" } diff --git a/bin/dlog b/bin/dlog index 1e80db97b37..2e8c2a32add 100755 --- a/bin/dlog +++ b/bin/dlog @@ -38,8 +38,8 @@ DLOG_CLASSPATH=$(set_module_classpath ${DLOG_MODULE_PATH}) # default variables DEFAULT_CONF=${BK_HOME}/conf/bk_server.conf DEFAULT_CLI_CONF=${BK_HOME}/conf/bk_server.conf -DEFAULT_LOG_CONF=${BK_HOME}/conf/log4j.properties -DEFAULT_CLI_LOG_CONF=${BK_HOME}/conf/log4j.cli.properties +DEFAULT_LOG_CONF=${BK_HOME}/conf/log4j2.xml +DEFAULT_CLI_LOG_CONF=${BK_HOME}/conf/log4j2.cli.xml dlog_help() { cat < (, )+ - -# DEFAULT: console appender only -log4j.rootLogger=ERROR, CONSOLE - -# Example with rolling log file -#log4j.rootLogger=DEBUG, CONSOLE, ROLLINGFILE - -# Example with rolling log file and tracing -#log4j.rootLogger=TRACE, CONSOLE, ROLLINGFILE, TRACEFILE - -# -# Log INFO level and above messages to the console -# -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.Threshold=INFO -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} - %-5p - [%t:%C{1}@%L] - %m%n -log4j.logger.org.apache.bookkeeper.benchmark=INFO - -# -# Add ROLLINGFILE to rootLogger to get log file output -# Log DEBUG level and above messages to a log file -log4j.appender.ROLLINGFILE=org.apache.log4j.DailyRollingFileAppender -log4j.appender.ROLLINGFILE.Threshold=DEBUG -log4j.appender.ROLLINGFILE.File=bookkeeper-benchmark.log -log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout -log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} - %-5p - [%t:%C{1}@%L] - %m%n - -# Max log file size of 10MB -log4j.appender.ROLLINGFILE.MaxFileSize=10MB -# uncomment the next line to limit number of backup files -#log4j.appender.ROLLINGFILE.MaxBackupIndex=10 - -# -# Add TRACEFILE to rootLogger to get log file output -# Log DEBUG level and above messages to a log file -log4j.appender.TRACEFILE=org.apache.log4j.FileAppender -log4j.appender.TRACEFILE.Threshold=TRACE -log4j.appender.TRACEFILE.File=bookkeeper_trace.log - -log4j.appender.TRACEFILE.layout=org.apache.log4j.PatternLayout -### Notice we are including log4j's NDC here (%x) -log4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} - %-5p [%t:%C{1}@%L][%x] - %m%n diff --git a/bookkeeper-benchmark/conf/log4j2.xml b/bookkeeper-benchmark/conf/log4j2.xml new file mode 100644 index 00000000000..21257d6dc3a --- /dev/null +++ b/bookkeeper-benchmark/conf/log4j2.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bookkeeper-common/pom.xml b/bookkeeper-common/pom.xml index c88a002f807..5667c3809cb 100644 --- a/bookkeeper-common/pom.xml +++ b/bookkeeper-common/pom.xml @@ -85,18 +85,6 @@ commons-lang3 test - - org.apache.logging.log4j - log4j-core - ${log4j.version} - test - - - org.apache.logging.log4j - log4j-slf4j-impl - ${log4j.version} - test - diff --git a/bookkeeper-dist/all/build.gradle b/bookkeeper-dist/all/build.gradle index 486eede5a84..523718e460e 100644 --- a/bookkeeper-dist/all/build.gradle +++ b/bookkeeper-dist/all/build.gradle @@ -36,7 +36,6 @@ dependencies { implementation project(':stream:server') implementation project(':bookkeeper-tools') implementation depLibs.jsr305 - runtimeOnly depLibs.log4j12api runtimeOnly depLibs.log4jSlf4jImpl runtimeOnly depLibs.log4jCore implementation (depLibs.zookeeperTest) { diff --git a/bookkeeper-dist/all/pom.xml b/bookkeeper-dist/all/pom.xml index 2fb45d74985..b9ddb97a9fb 100644 --- a/bookkeeper-dist/all/pom.xml +++ b/bookkeeper-dist/all/pom.xml @@ -103,20 +103,6 @@ ${project.version} - - - org.apache.logging.log4j - log4j-1.2-api - - - org.apache.logging.log4j - log4j-core - - - org.apache.logging.log4j - log4j-slf4j-impl - - org.xerial.snappy diff --git a/bookkeeper-dist/bkctl/build.gradle b/bookkeeper-dist/bkctl/build.gradle index 23a4aa07853..c2e9d41dc5a 100644 --- a/bookkeeper-dist/bkctl/build.gradle +++ b/bookkeeper-dist/bkctl/build.gradle @@ -69,8 +69,8 @@ distributions { "bk_server.conf", "bkenv.sh", "jaas_example.conf", - "log4j.cli.properties", - "log4j.shell.properties", + "log4j2.cli.xml", + "log4j2.shell.xml", "nettyenv.sh", "default_rocksdb.conf", "entry_location_rocksdb.conf", diff --git a/bookkeeper-dist/bkctl/pom.xml b/bookkeeper-dist/bkctl/pom.xml index dc40b6e4d49..f26e8b0b694 100644 --- a/bookkeeper-dist/bkctl/pom.xml +++ b/bookkeeper-dist/bkctl/pom.xml @@ -44,20 +44,6 @@ - - - - org.apache.logging.log4j - log4j-1.2-api - - - org.apache.logging.log4j - log4j-core - - - org.apache.logging.log4j - log4j-slf4j-impl - diff --git a/bookkeeper-dist/server/build.gradle b/bookkeeper-dist/server/build.gradle index 752bccf0e8d..0c1540e7f62 100644 --- a/bookkeeper-dist/server/build.gradle +++ b/bookkeeper-dist/server/build.gradle @@ -35,7 +35,6 @@ dependencies { implementation project(':stream:distributedlog:core') implementation project(':stream:server') implementation project(':bookkeeper-tools') - runtimeOnly depLibs.log4j12api runtimeOnly depLibs.log4jSlf4jImpl runtimeOnly depLibs.log4jCore runtimeOnly (depLibs.zookeeperTest) { diff --git a/bookkeeper-dist/server/pom.xml b/bookkeeper-dist/server/pom.xml index 6c61b3637fc..b9fc5de8cf0 100644 --- a/bookkeeper-dist/server/pom.xml +++ b/bookkeeper-dist/server/pom.xml @@ -83,20 +83,6 @@ ${project.version} - - - org.apache.logging.log4j - log4j-1.2-api - - - org.apache.logging.log4j - log4j-core - - - org.apache.logging.log4j - log4j-slf4j-impl - - org.xerial.snappy diff --git a/bookkeeper-dist/src/assemble/bkctl.xml b/bookkeeper-dist/src/assemble/bkctl.xml index 6308ecb10f3..718a9c85663 100644 --- a/bookkeeper-dist/src/assemble/bkctl.xml +++ b/bookkeeper-dist/src/assemble/bkctl.xml @@ -38,8 +38,8 @@ bk_server.conf bkenv.sh jaas_example.conf - log4j.cli.properties - log4j.shell.properties + log4j2.cli.xml + log4j2.shell.xml nettyenv.sh default_rocksdb.conf entry_location_rocksdb.conf diff --git a/bookkeeper-dist/src/main/resources/LICENSE-all.bin.txt b/bookkeeper-dist/src/main/resources/LICENSE-all.bin.txt index ab3807615b2..2dabc1fa3ea 100644 --- a/bookkeeper-dist/src/main/resources/LICENSE-all.bin.txt +++ b/bookkeeper-dist/src/main/resources/LICENSE-all.bin.txt @@ -248,7 +248,6 @@ Apache Software License, Version 2. - lib/io.vertx-vertx-core-3.9.8.jar [15] - lib/io.vertx-vertx-web-3.9.8.jar [16] - lib/io.vertx-vertx-web-common-3.9.8.jar [16] -- lib/org.apache.logging.log4j-log4j-1.2-api-2.17.2.jar [17] - lib/org.apache.logging.log4j-log4j-api-2.17.2.jar [17] - lib/org.apache.logging.log4j-log4j-core-2.17.2.jar [17] - lib/org.apache.logging.log4j-log4j-slf4j-impl-2.17.2.jar [17] diff --git a/bookkeeper-dist/src/main/resources/LICENSE-bkctl.bin.txt b/bookkeeper-dist/src/main/resources/LICENSE-bkctl.bin.txt index b803f539e1c..d4759c5351d 100644 --- a/bookkeeper-dist/src/main/resources/LICENSE-bkctl.bin.txt +++ b/bookkeeper-dist/src/main/resources/LICENSE-bkctl.bin.txt @@ -237,7 +237,6 @@ Apache Software License, Version 2. - lib/io.netty-netty-transport-classes-epoll-4.1.75.Final.jar [11] - lib/io.netty-netty-transport-native-epoll-4.1.75.Final-linux-x86_64.jar [11] - lib/io.netty-netty-transport-native-unix-common-4.1.75.Final.jar [11] -- lib/org.apache.logging.log4j-log4j-1.2-api-2.17.2.jar [16] - lib/org.apache.logging.log4j-log4j-api-2.17.2.jar [16] - lib/org.apache.logging.log4j-log4j-core-2.17.2.jar [16] - lib/org.apache.logging.log4j-log4j-slf4j-impl-2.17.2.jar [16] diff --git a/bookkeeper-dist/src/main/resources/LICENSE-server.bin.txt b/bookkeeper-dist/src/main/resources/LICENSE-server.bin.txt index dc419e532de..8539216fee9 100644 --- a/bookkeeper-dist/src/main/resources/LICENSE-server.bin.txt +++ b/bookkeeper-dist/src/main/resources/LICENSE-server.bin.txt @@ -248,7 +248,6 @@ Apache Software License, Version 2. - lib/io.vertx-vertx-core-3.9.8.jar [15] - lib/io.vertx-vertx-web-3.9.8.jar [16] - lib/io.vertx-vertx-web-common-3.9.8.jar [16] -- lib/org.apache.logging.log4j-log4j-1.2-api-2.17.2.jar [17] - lib/org.apache.logging.log4j-log4j-api-2.17.2.jar [17] - lib/org.apache.logging.log4j-log4j-core-2.17.2.jar [17] - lib/org.apache.logging.log4j-log4j-slf4j-impl-2.17.2.jar [17] diff --git a/bookkeeper-server/pom.xml b/bookkeeper-server/pom.xml index b51615c5844..bc7886d7bfa 100644 --- a/bookkeeper-server/pom.xml +++ b/bookkeeper-server/pom.xml @@ -55,18 +55,6 @@ ${project.parent.version} test - - org.apache.logging.log4j - log4j-core - ${log4j.version} - test - - - org.apache.logging.log4j - log4j-slf4j-impl - ${log4j.version} - test - org.apache.zookeeper zookeeper diff --git a/bookkeeper-server/src/main/resources/log4j.properties b/bookkeeper-server/src/main/resources/log4j.properties deleted file mode 100644 index 7703c575bff..00000000000 --- a/bookkeeper-server/src/main/resources/log4j.properties +++ /dev/null @@ -1,38 +0,0 @@ -# -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# - -# -# Bookkeeper Logging Configuration -# - -# Format is " (, )+ - -# DEFAULT: console appender only, level INFO -bookkeeper.root.logger=INFO,CONSOLE -log4j.rootLogger=${bookkeeper.root.logger} - -# -# Log INFO level and above messages to the console -# -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} - %-5p - [%t:%C{1}@%L] - %m%n - diff --git a/bookkeeper-server/src/main/resources/log4j2.xml b/bookkeeper-server/src/main/resources/log4j2.xml new file mode 100644 index 00000000000..3e3e4bc8c8e --- /dev/null +++ b/bookkeeper-server/src/main/resources/log4j2.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/buildtools/src/main/resources/log4j.properties b/buildtools/src/main/resources/log4j.properties deleted file mode 100644 index 10ae6bfcbba..00000000000 --- a/buildtools/src/main/resources/log4j.properties +++ /dev/null @@ -1,42 +0,0 @@ -# -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# - -# -# Bookkeeper Logging Configuration -# - -# Format is " (, )+ - -# DEFAULT: console appender only, level INFO -bookkeeper.root.logger=INFO,CONSOLE -log4j.rootLogger=${bookkeeper.root.logger} - -# -# Log INFO level and above messages to the console -# -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} - %-5p - [%t:%C{1}@%L] - %m%n - -#disable zookeeper logging -log4j.logger.org.apache.zookeeper=OFF -log4j.logger.org.apache.bookkeeper.bookie=INFO -log4j.logger.org.apache.bookkeeper.meta=INFO diff --git a/buildtools/src/main/resources/log4j2.xml b/buildtools/src/main/resources/log4j2.xml new file mode 100644 index 00000000000..050035d8002 --- /dev/null +++ b/buildtools/src/main/resources/log4j2.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + diff --git a/conf/bk_cli_env.sh b/conf/bk_cli_env.sh index 8faa03d3651..dde6c4b3110 100644 --- a/conf/bk_cli_env.sh +++ b/conf/bk_cli_env.sh @@ -50,7 +50,8 @@ # CLI_LOG_FILE="bookkeeper-cli.log" # Log level & appender -# CLI_ROOT_LOGGER="INFO,CONSOLE" +# CLI_ROOT_LOG_LEVEL="INFO" +# CLI_ROOT_LOG_APPENDER="CONSOLE" ################################# # JVM memory options diff --git a/conf/bkenv.sh b/conf/bkenv.sh index f6d061611fc..570e0c6f4a1 100644 --- a/conf/bkenv.sh +++ b/conf/bkenv.sh @@ -63,7 +63,8 @@ # BOOKIE_LOG_FILE="bookkeeper.log" # Log level & appender -# BOOKIE_ROOT_LOGGER="INFO,CONSOLE" +# BOOKIE_ROOT_LOG_LEVEL="INFO" +# BOOKIE_ROOT_LOG_APPENDER="CONSOLE" ################################# # BookKeeper JVM memory options diff --git a/conf/log4j.cli.properties b/conf/log4j.cli.properties deleted file mode 100644 index a5750334981..00000000000 --- a/conf/log4j.cli.properties +++ /dev/null @@ -1,62 +0,0 @@ -# -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# - -# -# BookKeeper CLI (experimental) log4j configuration (used by `bin/bookkeeper-cli.sh`) -# - -# DEFAULT: console appender only -# Define some default values that can be overridden by system properties -bookkeeper.cli.root.logger=INFO,CONSOLE -bookkeeper.cli.log.dir=logs -bookkeeper.cli.log.file=bookkeeper-cli.log - -log4j.rootLogger=${bookkeeper.cli.root.logger} - -# -# Log INFO level and above messages to the console -# -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.Threshold=INFO -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p %m%n - -# verbose console logging -log4j.appender.VERBOSECONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.VERBOSECONSOLE.Threshold=INFO -log4j.appender.VERBOSECONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.VERBOSECONSOLE.layout.ConversionPattern=%m%n - -# file logging -log4j.appender.ROLLINGFILE=org.apache.log4j.DailyRollingFileAppender -log4j.appender.ROLLINGFILE.Threshold=INFO -log4j.appender.ROLLINGFILE.File=${bookkeeper.cli.log.dir}/${bookkeeper.cli.log.file} -log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout -log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} - %-5p - [%t:%C{1}@%L] - %m%n - -log4j.logger.verbose=INFO,VERBOSECONSOLE -log4j.logger.org.apache.zookeeper=ERROR -log4j.logger.org.apache.bookkeeper=ERROR -log4j.logger.org.apache.bookkeeper.bookie.BookieShell=INFO -log4j.logger.org.apache.bookkeeper.client.BookKeeperAdmin=INFO -log4j.logger.org.apache.bookkeeper.bookie.InterleavedStorageRegenerateIndexOp=INFO -log4j.logger.org.apache.bookkeeper.tools.cli.commands.bookies.InstanceIdCommand=INFO - diff --git a/conf/log4j.properties b/conf/log4j.properties deleted file mode 100644 index cee7364bc40..00000000000 --- a/conf/log4j.properties +++ /dev/null @@ -1,77 +0,0 @@ -# -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# - -# -# BookKeeper Daemon log4j configuration -# - -# Format is " (, )+ - -# DEFAULT: console appender only -# Define some default values that can be overridden by system properties -bookkeeper.root.logger=WARN,CONSOLE -bookkeeper.log.dir=. -bookkeeper.log.file=bookkeeper-server.log - -log4j.rootLogger=${bookkeeper.root.logger} - -# Example with rolling log file -#log4j.rootLogger=DEBUG, CONSOLE, ROLLINGFILE - -# Example with rolling log file and tracing -#log4j.rootLogger=TRACE, CONSOLE, ROLLINGFILE, TRACEFILE - -# -# Log INFO level and above messages to the console -# -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.Threshold=INFO -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} - %-5p - [%t:%C{1}@%L] - %m%n - -# -# Add ROLLINGFILE to rootLogger to get log file output -# Log DEBUG level and above messages to a log file -log4j.appender.ROLLINGFILE=org.apache.log4j.DailyRollingFileAppender - -log4j.appender.ROLLINGFILE.Threshold=INFO -log4j.appender.ROLLINGFILE.File=${bookkeeper.log.dir}/${bookkeeper.log.file} -log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout -log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} - %-5p - [%t:%C{1}@%L] - %m%n - -# Max log file size of 10MB -#log4j.appender.ROLLINGFILE.MaxFileSize=10MB -# uncomment the next line to limit number of backup files -#log4j.appender.ROLLINGFILE.MaxBackupIndex=10 - -log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout -log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} - %-5p [%t:%C{1}@%L] - %m%n - -# -# Add TRACEFILE to rootLogger to get log file output -# Log DEBUG level and above messages to a log file -log4j.appender.TRACEFILE=org.apache.log4j.FileAppender -log4j.appender.TRACEFILE.Threshold=TRACE -log4j.appender.TRACEFILE.File=bookkeeper-trace.log - -log4j.appender.TRACEFILE.layout=org.apache.log4j.PatternLayout -### Notice we are including log4j's NDC here (%x) -log4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} - %-5p [%t:%C{1}@%L][%x] - %m%n diff --git a/conf/log4j.shell.properties b/conf/log4j.shell.properties deleted file mode 100644 index 32b963e35bb..00000000000 --- a/conf/log4j.shell.properties +++ /dev/null @@ -1,45 +0,0 @@ -# -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# - -# -# BookieShell log4j configuration -# - -# DEFAULT: console appender only -# Define some default values that can be overridden by system properties -bookkeeper.root.logger=INFO,CONSOLE - -log4j.rootLogger=${bookkeeper.root.logger} - -# -# Log INFO level and above messages to the console -# -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.Threshold=INFO -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p %m%n - -log4j.logger.org.apache.zookeeper=INFO -log4j.logger.org.apache.bookkeeper=INFO -log4j.logger.org.apache.bookkeeper.bookie.BookieShell=INFO -log4j.logger.org.apache.bookkeeper.client.BookKeeperAdmin=INFO -log4j.logger.org.apache.bookkeeper.bookie.InterleavedStorageRegenerateIndexOp=INFO -log4j.logger.org.apache.bookkeeper.tools.cli.commands.bookies.InstanceIdCommand=INFO diff --git a/conf/log4j2.cli.xml b/conf/log4j2.cli.xml new file mode 100644 index 00000000000..3a1d2fa4ffb --- /dev/null +++ b/conf/log4j2.cli.xml @@ -0,0 +1,53 @@ + + + + + . + bookkeeper-server.log + INFO + CONSOLE + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/log4j2.shell.xml b/conf/log4j2.shell.xml new file mode 100644 index 00000000000..7c15d5d6cfa --- /dev/null +++ b/conf/log4j2.shell.xml @@ -0,0 +1,43 @@ + + + + + INFO + CONSOLE + + + + + + + + + + + + + + + + + + diff --git a/conf/log4j2.xml b/conf/log4j2.xml new file mode 100644 index 00000000000..61c92a59353 --- /dev/null +++ b/conf/log4j2.xml @@ -0,0 +1,49 @@ + + + + + . + bookkeeper-server.log + INFO + CONSOLE + + + + + + + + + + + + + + + + + + + + + + diff --git a/dependencies.gradle b/dependencies.gradle index e3737800ccd..517eb0661df 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -174,7 +174,6 @@ depLibs = [ junitFoundation: "com.nordstrom.tools:junit-foundation:${depVersions.junitFoundation}", kerbySimpleKdc: "org.apache.kerby:kerb-simplekdc:${depVersions.kerby}", log4jSlf4jImpl: "org.apache.logging.log4j:log4j-slf4j-impl:${depVersions.log4j}", - log4j12api: "org.apache.logging.log4j:log4j-1.2-api:${depVersions.log4j}", log4jCore: "org.apache.logging.log4j:log4j-core:${depVersions.log4j}", lombok: "org.projectlombok:lombok:${depVersions.lombok}", lz4: "net.jpountz.lz4:lz4:${depVersions.lz4}", diff --git a/dev/stats-doc-gen b/dev/stats-doc-gen index 3a20aef8a59..ae8969fad1d 100755 --- a/dev/stats-doc-gen +++ b/dev/stats-doc-gen @@ -36,13 +36,14 @@ CLI_JAR=$(find_module_jar ${CLI_MODULE_PATH} ${CLI_MODULE_NAME}) # set up the classpath CLI_CLASSPATH=$(set_module_classpath ${CLI_MODULE_PATH}) -DEFAULT_LOG_CONF=${BK_HOME}/conf/log4j.cli.properties +DEFAULT_LOG_CONF=${BK_HOME}/conf/log4j2.cli.xml if [ -z "${CLI_LOG_CONF}" ]; then CLI_LOG_CONF=${DEFAULT_LOG_CONF} fi CLI_LOG_DIR=${CLI_LOG_DIR:-"$BK_HOME/logs"} CLI_LOG_FILE=${CLI_LOG_FILE:-"stats-doc-gen.log"} -CLI_ROOT_LOGGER=${CLI_ROOT_LOGGER:-"INFO,ROLLINGFILE"} +CLI_ROOT_LOG_LEVEL=${CLI_ROOT_LOG_LEVEL:-"INFO"} +CLI_ROOT_LOG_APPENDER=${CLI_ROOT_LOG_APPENDER:-"ROLLINGFILE"} # add all dependencies in the classpath ALL_MODULE_PATH=bookkeeper-dist/all @@ -56,7 +57,7 @@ CLI_CLASSPATH="`dirname $CLI_LOG_CONF`:$CLI_CLASSPATH" BOOKIE_OPTS=$(build_bookie_opts) GC_OPTS=$(build_cli_jvm_opts ${CLI_LOG_DIR} "stats-doc-gen-gc.log") NETTY_OPTS=$(build_netty_opts) -LOGGING_OPTS=$(build_cli_logging_opts ${CLI_LOG_CONF} ${CLI_LOG_DIR} ${CLI_LOG_FILE} ${CLI_ROOT_LOGGER}) +LOGGING_OPTS=$(build_cli_logging_opts ${CLI_LOG_CONF} ${CLI_ROOT_LOG_LEVEL} ${CLI_ROOT_LOG_APPENDER} ${CLI_LOG_DIR} ${CLI_LOG_FILE}) OPTS="${OPTS} -cp ${CLI_CLASSPATH} ${BOOKIE_OPTS} ${GC_OPTS} ${NETTY_OPTS} ${LOGGING_OPTS} ${CLI_EXTRA_OPTS}" diff --git a/docker/README.md b/docker/README.md index b15d9051927..4bb3c782d86 100644 --- a/docker/README.md +++ b/docker/README.md @@ -223,7 +223,7 @@ Default value is "/data/bookkeeper", which contains volumes `/data/bookkeeper/jo ### Configure files under /opt/bookkeeper/conf These files is originally un-tared from the bookkeeper building binary, such as [bookkeeper-server-4.4.0-bin.tar.tgz](https://archive.apache.org/dist/bookkeeper/bookkeeper-4.4.0/bookkeeper-4.4.0-src.tar.gz), and it comes from [these files](https://github.com/apache/bookkeeper/tree/master/bookkeeper-server/conf) in Bookkeeper repo. -Usually we could config files bk_server.conf, bkenv.sh, log4j.properties, and log4j.shell.properties. Please read and understand them before you do the configuration. +Usually we could config files bk_server.conf, bkenv.sh, log4j2.xml, and log4j2.shell.xml. Please read and understand them before you do the configuration. ### Caveats diff --git a/microbenchmarks/pom.xml b/microbenchmarks/pom.xml index 746421cfc8f..43096e97217 100644 --- a/microbenchmarks/pom.xml +++ b/microbenchmarks/pom.xml @@ -38,18 +38,6 @@ jmh-generator-annprocess provided - - org.apache.logging.log4j - log4j-1.2-api - - - org.apache.logging.log4j - log4j-core - - - org.apache.logging.log4j - log4j-slf4j-impl - org.apache.bookkeeper bookkeeper-server diff --git a/pom.xml b/pom.xml index 886a0c1d4d4..6cce137fc2e 100644 --- a/pom.xml +++ b/pom.xml @@ -253,11 +253,6 @@ slf4j-api ${slf4j.version} - - org.apache.logging.log4j - log4j-1.2-api - ${log4j.version} - org.apache.logging.log4j log4j-core @@ -795,6 +790,14 @@ org.slf4j slf4j-api + + org.apache.logging.log4j + log4j-core + + + org.apache.logging.log4j + log4j-slf4j-impl + commons-configuration commons-configuration @@ -810,16 +813,6 @@ hamcrest-all test - - org.apache.logging.log4j - log4j-core - test - - - org.apache.logging.log4j - log4j-slf4j-impl - test - org.mockito mockito-core @@ -1189,7 +1182,7 @@ maven-surefire-plugin ${maven-surefire-plugin.version} - -Xmx2G -Djava.net.preferIPv4Stack=true -Dbookkeeper.root.logger=DEBUG,CONSOLE + -Xmx2G -Djava.net.preferIPv4Stack=true -Dbookkeeper.log.root.level=INFO -Dbookkeeper.log.root.appender=CONSOLE false ${forkCount.variable} false diff --git a/site/_data/cli/bookkeeper.yaml b/site/_data/cli/bookkeeper.yaml index fd780f151f3..37c62804aca 100644 --- a/site/_data/cli/bookkeeper.yaml +++ b/site/_data/cli/bookkeeper.yaml @@ -24,7 +24,7 @@ commands: env_vars: - name: BOOKIE_LOG_CONF description: The Log4j configuration file. - default: bookkeeper-server/conf/log4j.properties + default: bookkeeper-server/conf/log4j2.xml - name: BOOKIE_CONF description: The configuration file for the bookie. default: bookkeeper-server/conf/bk_server.conf diff --git a/site/docs/latest/admin/bookies.md b/site/docs/latest/admin/bookies.md index 418c4ca1b79..35f629c847f 100644 --- a/site/docs/latest/admin/bookies.md +++ b/site/docs/latest/admin/bookies.md @@ -71,10 +71,10 @@ Parameter | Description | Default BookKeeper uses [slf4j](http://www.slf4j.org/) for logging, with [log4j](https://logging.apache.org/log4j/2.x/) bindings enabled by default. -To enable logging for a bookie, create a `log4j.properties` file and point the `BOOKIE_LOG_CONF` environment variable to the configuration file. Here's an example: +To enable logging for a bookie, create a `log4j2.xml` file and point the `BOOKIE_LOG_CONF` environment variable to the configuration file. Here's an example: ```shell -$ export BOOKIE_LOG_CONF=/some/path/log4j.properties +$ export BOOKIE_LOG_CONF=/some/path/log4j2.xml $ bin/bookkeeper bookie ``` diff --git a/site3/website/docs/reference/cli.md b/site3/website/docs/reference/cli.md index 3aee1fe3769..b9b1d6ad7df 100644 --- a/site3/website/docs/reference/cli.md +++ b/site3/website/docs/reference/cli.md @@ -9,14 +9,14 @@ Manages bookies. #### Environment variables -| Environment variable | Description | Default | -| ------------------ | ----------- | ------ | -`BOOKIE_LOG_CONF` | The Log4j configuration file. | `${bookkeeperHome}/bookkeeper-server/conf/log4j.properties` | -`BOOKIE_CONF` | The configuration file for the bookie. | `${bookkeeperHome}/bookkeeper-server/conf/bk_server.conf` | -`BOOKIE_EXTRA_CLASSPATH` | Extra paths to add to BookKeeper's [classpath](https://en.wikipedia.org/wiki/Classpath_(Java)). | | -`ENTRY_FORMATTER_CLASS` | The entry formatter class used to format entries. | | -`BOOKIE_PID_DIR` | The directory where the bookie server PID file is stored. | | -`BOOKIE_STOP_TIMEOUT` | The wait time before forcefully killing the bookie server instance if stopping it is not successful. | | +| Environment variable | Description | Default | +|--------------------------|------------------------------------------------------------------------------------------------------|-----------------------------------------------------------| +| `BOOKIE_LOG_CONF` | The Log4j configuration file. | `${bookkeeperHome}/bookkeeper-server/conf/log4j2.xml` | +| `BOOKIE_CONF` | The configuration file for the bookie. | `${bookkeeperHome}/bookkeeper-server/conf/bk_server.conf` | +| `BOOKIE_EXTRA_CLASSPATH` | Extra paths to add to BookKeeper's [classpath](https://en.wikipedia.org/wiki/Classpath_(Java)). | | +| `ENTRY_FORMATTER_CLASS` | The entry formatter class used to format entries. | | +| `BOOKIE_PID_DIR` | The directory where the bookie server PID file is stored. | | +| `BOOKIE_STOP_TIMEOUT` | The wait time before forcefully killing the bookie server instance if stopping it is not successful. | | #### Commands diff --git a/stream/bin/streamstorage b/stream/bin/streamstorage index a85c6e70d32..b0877789b52 100755 --- a/stream/bin/streamstorage +++ b/stream/bin/streamstorage @@ -22,7 +22,7 @@ BINDIR=$(dirname "$0") SS_HOME=`cd $BINDIR/..;pwd` DEFAULT_STANDALONE_CONF=$SS_HOME/conf/standalone.conf -DEFAULT_LOG_CONF=$SS_HOME/conf/log4j.properties +DEFAULT_LOG_CONF=$SS_HOME/conf/log4j2.xml if [ -f "$SS_HOME/conf/streamstorage_env.sh" ] then @@ -121,7 +121,7 @@ fi SS_CLASSPATH="$SS_JAR:$SS_CLASSPATH:$SS_EXTRA_CLASSPATH" SS_CLASSPATH="`dirname $SS_LOG_CONF`:$SS_CLASSPATH" -OPTS="$OPTS -Dlog4j.configuration=`basename $SS_LOG_CONF`" +OPTS="$OPTS -Dlog4j.configurationFile=`basename $SS_LOG_CONF`" # Ensure we can read bigger content from ZK. (It might be # rarely needed when trying to list many z-nodes under a @@ -133,14 +133,17 @@ OPTS="-cp $SS_CLASSPATH $OPTS" OPTS="$OPTS $SS_EXTRA_OPTS" # log directory & file -SS_ROOT_LOGGER=${SS_ROOT_LOGGER:-"INFO,CONSOLE"} SS_LOG_DIR=${SS_LOG_DIR:-"$SS_HOME/logs"} SS_LOG_FILE=${SS_LOG_FILE:-"stream-storage.log"} +SS_ROOT_LOG_LEVEL=${SS_ROOT_LOG_LEVEL:-"INFO"} +SS_ROOT_LOG_APPENDER=${SS_ROOT_LOG_APPENDER:-"CONSOLE"} + #Configure log configuration system properties -OPTS="$OPTS -Dstreamstorage.root.logger=$SS_ROOT_LOGGER" OPTS="$OPTS -Dstreamstorage.log.dir=$SS_LOG_DIR" OPTS="$OPTS -Dstreamstorage.log.file=$SS_LOG_FILE" +OPTS="$OPTS -Dstreamstorage.log.root.level=$SS_ROOT_LOG_LEVEL" +OPTS="$OPTS -Dstreamstorage.log.root.appender=$SS_ROOT_LOG_APPENDER" #Change to SS_HOME to support relative paths cd "$SS_HOME" diff --git a/stream/bin/streamstorage-cli b/stream/bin/streamstorage-cli index 6a1df7810d8..b3453040165 100755 --- a/stream/bin/streamstorage-cli +++ b/stream/bin/streamstorage-cli @@ -22,7 +22,7 @@ BINDIR=$(dirname "$0") SS_HOME=`cd $BINDIR/..;pwd` DEFAULT_ENDPOINT="127.0.0.1:4181" -DEFAULT_LOG_CONF=$SS_HOME/conf/log4j.cli.properties +DEFAULT_LOG_CONF=$SS_HOME/conf/log4j2.cli.xml if [ -f "$SS_HOME/conf/streamstorage_cli_env.sh" ] then @@ -88,7 +88,7 @@ fi SS_CLASSPATH="$SS_JAR:$SS_CLASSPATH:$SS_EXTRA_CLASSPATH" SS_CLASSPATH="`dirname $SS_LOG_CONF`:$SS_CLASSPATH" -OPTS="$OPTS -Dlog4j.configuration=`basename $SS_LOG_CONF`" +OPTS="$OPTS -Dlog4j.configurationFile=`basename $SS_LOG_CONF`" OPTS="$OPTS -Djava.net.preferIPv4Stack=true" OPTS="-cp $SS_CLASSPATH $OPTS" @@ -96,14 +96,16 @@ OPTS="-cp $SS_CLASSPATH $OPTS" OPTS="$OPTS $SS_EXTRA_OPTS" # log directory & file -SS_ROOT_LOGGER=${SS_ROOT_LOGGER:-"INFO,CONSOLE"} SS_LOG_DIR=${SS_LOG_DIR:-"$SS_HOME/logs"} SS_LOG_FILE=${SS_LOG_FILE:-"stream-storage-cli.log"} +SS_ROOT_LOG_LEVEL=${SS_ROOT_LOGGER:-"INFO"} +SS_ROOT_LOG_APPENDER=${SS_ROOT_LOGGER:-"CONSOLE"} #Configure log configuration system properties -OPTS="$OPTS -Dstreamstorage.root.logger=$SS_ROOT_LOGGER" OPTS="$OPTS -Dstreamstorage.log.dir=$SS_LOG_DIR" OPTS="$OPTS -Dstreamstorage.log.file=$SS_LOG_FILE" +OPTS="$OPTS -Dstreamstorage.log.root.level=$SS_ROOT_LOG_LEVEL" +OPTS="$OPTS -Dstreamstorage.log.root.appender=$SS_ROOT_LOG_APPENDER" #Change to SS_HOME to support relative paths cd "$SS_HOME" diff --git a/stream/conf/log4j.cli.properties b/stream/conf/log4j.cli.properties deleted file mode 100644 index 27f898fade9..00000000000 --- a/stream/conf/log4j.cli.properties +++ /dev/null @@ -1,73 +0,0 @@ -# -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# - -# Format is " (, )+ - -# DEFAULT: console appender only -# Define some default values that can be overridden by system properties -streamstorage.root.logger=INFO,CONSOLE -streamstorage.log.dir=logs -streamstorage.log.file=stream-storage-cli.log - -log4j.rootLogger=${streamstorage.root.logger} - -# Example with rolling log file -#log4j.rootLogger=DEBUG, CONSOLE, ROLLINGFILE - -# Example with rolling log file and tracing -#log4j.rootLogger=TRACE, CONSOLE, ROLLINGFILE, TRACEFILE - -# -# Log INFO level and above messages to the console -# -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.Threshold=INFO -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} - %-5p - [%t:%C{1}@%L] - %m%n - -# -# Add ROLLINGFILE to rootLogger to get log file output -# Log DEBUG level and above messages to a log file -log4j.appender.ROLLINGFILE=org.apache.log4j.DailyRollingFileAppender - -log4j.appender.ROLLINGFILE.Threshold=INFO -log4j.appender.ROLLINGFILE.File=${streamstorage.log.dir}/${streamstorage.log.file} -log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout -log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} - %-5p - [%t:%C{1}@%L] - %m%n - -# Max log file size of 10MB -#log4j.appender.ROLLINGFILE.MaxFileSize=10MB -# uncomment the next line to limit number of backup files -#log4j.appender.ROLLINGFILE.MaxBackupIndex=10 - -log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout -log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} - %-5p [%t:%C{1}@%L] - %m%n - -# -# Add TRACEFILE to rootLogger to get log file output -# Log DEBUG level and above messages to a log file -log4j.appender.TRACEFILE=org.apache.log4j.FileAppender -log4j.appender.TRACEFILE.Threshold=TRACE -log4j.appender.TRACEFILE.File=streamstorage-trace.log - -log4j.appender.TRACEFILE.layout=org.apache.log4j.PatternLayout -### Notice we are including log4j's NDC here (%x) -log4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} - %-5p [%t:%C{1}@%L][%x] - %m%n diff --git a/stream/conf/log4j.properties b/stream/conf/log4j.properties deleted file mode 100644 index d6c14acddec..00000000000 --- a/stream/conf/log4j.properties +++ /dev/null @@ -1,73 +0,0 @@ -# -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# - -# Format is " (, )+ - -# DEFAULT: console appender only -# Define some default values that can be overridden by system properties -streamstorage.root.logger=WARN,CONSOLE -streamstorage.log.dir=logs -streamstorage.log.file=stream-storage.log - -log4j.rootLogger=${streamstorage.root.logger} - -# Example with rolling log file -#log4j.rootLogger=DEBUG, CONSOLE, ROLLINGFILE - -# Example with rolling log file and tracing -#log4j.rootLogger=TRACE, CONSOLE, ROLLINGFILE, TRACEFILE - -# -# Log INFO level and above messages to the console -# -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.Threshold=INFO -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} - %-5p - [%t:%C{1}@%L] - %m%n - -# -# Add ROLLINGFILE to rootLogger to get log file output -# Log DEBUG level and above messages to a log file -log4j.appender.ROLLINGFILE=org.apache.log4j.DailyRollingFileAppender - -log4j.appender.ROLLINGFILE.Threshold=INFO -log4j.appender.ROLLINGFILE.File=${streamstorage.log.dir}/${streamstorage.log.file} -log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout -log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} - %-5p - [%t:%C{1}@%L] - %m%n - -# Max log file size of 10MB -#log4j.appender.ROLLINGFILE.MaxFileSize=10MB -# uncomment the next line to limit number of backup files -#log4j.appender.ROLLINGFILE.MaxBackupIndex=10 - -log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout -log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} - %-5p [%t:%C{1}@%L] - %m%n - -# -# Add TRACEFILE to rootLogger to get log file output -# Log DEBUG level and above messages to a log file -log4j.appender.TRACEFILE=org.apache.log4j.FileAppender -log4j.appender.TRACEFILE.Threshold=TRACE -log4j.appender.TRACEFILE.File=streamstorage-trace.log - -log4j.appender.TRACEFILE.layout=org.apache.log4j.PatternLayout -### Notice we are including log4j's NDC here (%x) -log4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} - %-5p [%t:%C{1}@%L][%x] - %m%n diff --git a/stream/conf/log4j2.cli.xml b/stream/conf/log4j2.cli.xml new file mode 100644 index 00000000000..8c625013923 --- /dev/null +++ b/stream/conf/log4j2.cli.xml @@ -0,0 +1,49 @@ + + + + + logs + stream-storage-cli.log + INFO + CONSOLE + + + + + + + + + + + + + + + + + + + + + + diff --git a/stream/conf/log4j2.xml b/stream/conf/log4j2.xml new file mode 100644 index 00000000000..006e4bf6975 --- /dev/null +++ b/stream/conf/log4j2.xml @@ -0,0 +1,49 @@ + + + + + logs + stream-storage.log + INFO + CONSOLE + + + + + + + + + + + + + + + + + + + + + + diff --git a/stream/server/build.gradle b/stream/server/build.gradle index edf93434747..163cbd3f2e6 100644 --- a/stream/server/build.gradle +++ b/stream/server/build.gradle @@ -58,7 +58,6 @@ dependencies { implementation depLibs.zookeeper implementation depLibs.metricsCore implementation depLibs.snappy - implementation depLibs.log4j12api implementation depLibs.log4jSlf4jImpl implementation depLibs.log4jCore implementation depLibs.vertxCore diff --git a/tests/docker-images/statestore-image/bin/bkctl b/tests/docker-images/statestore-image/bin/bkctl index 139186a0642..77c917c7e2b 100755 --- a/tests/docker-images/statestore-image/bin/bkctl +++ b/tests/docker-images/statestore-image/bin/bkctl @@ -34,13 +34,14 @@ if [ -z "${CLI_CONF}" ]; then CLI_CONF=${DEFAULT_CONF} fi -DEFAULT_LOG_CONF=${BK_HOME}/conf/log4j.cli.properties +DEFAULT_LOG_CONF=${BK_HOME}/conf/log4j2.cli.xml if [ -z "${CLI_LOG_CONF}" ]; then CLI_LOG_CONF=${DEFAULT_LOG_CONF} fi CLI_LOG_DIR=${CLI_LOG_DIR:-"$BK_HOME/logs"} CLI_LOG_FILE=${CLI_LOG_FILE:-"bkctl.log"} -CLI_ROOT_LOGGER=${CLI_ROOT_LOGGER:-"INFO,ROLLINGFILE"} +CLI_ROOT_LOG_LEVEL=${CLI_ROOT_LOG_LEVEL:-"INFO"} +CLI_ROOT_LOG_APPENDER=${CLI_ROOT_LOG_APPENDER:-"ROLLINGFILE"} # Configure the classpath CLI_CLASSPATH="$CLI_JAR:$CLI_CLASSPATH:$CLI_EXTRA_CLASSPATH" @@ -50,7 +51,7 @@ CLI_CLASSPATH="`dirname $CLI_LOG_CONF`:$CLI_CLASSPATH" BOOKIE_OPTS=$(build_bookie_opts) GC_OPTS=$(build_cli_jvm_opts ${CLI_LOG_DIR} "bkctl-gc.log") NETTY_OPTS=$(build_netty_opts) -LOGGING_OPTS=$(build_cli_logging_opts ${CLI_LOG_CONF} ${CLI_LOG_DIR} ${CLI_LOG_FILE} ${CLI_ROOT_LOGGER}) +LOGGING_OPTS=$(build_cli_logging_opts ${CLI_LOG_CONF} ${CLI_ROOT_LOG_LEVEL} ${CLI_ROOT_LOG_APPENDER} ${CLI_LOG_DIR} ${CLI_LOG_FILE}) OPTS="${OPTS} -cp ${CLI_CLASSPATH} ${BOOKIE_OPTS} ${GC_OPTS} ${NETTY_OPTS} ${LOGGING_OPTS} ${CLI_EXTRA_OPTS}" diff --git a/tests/docker-images/statestore-image/bin/bkperf b/tests/docker-images/statestore-image/bin/bkperf index 0bfba831b2c..6d6501c64a9 100755 --- a/tests/docker-images/statestore-image/bin/bkperf +++ b/tests/docker-images/statestore-image/bin/bkperf @@ -33,13 +33,14 @@ if [ -z "${CLI_CONF}" ]; then CLI_CONF=${DEFAULT_CONF} fi -DEFAULT_LOG_CONF=${BK_HOME}/conf/log4j.cli.properties +DEFAULT_LOG_CONF=${BK_HOME}/conf/log4j2.cli.xml if [ -z "${CLI_LOG_CONF}" ]; then CLI_LOG_CONF=${DEFAULT_LOG_CONF} fi CLI_LOG_DIR=${CLI_LOG_DIR:-"$BK_HOME/logs"} CLI_LOG_FILE=${CLI_LOG_FILE:-"bkperf.log"} -CLI_ROOT_LOGGER=${CLI_ROOT_LOGGER:-"INFO,CONSOLE"} +CLI_ROOT_LOG_LEVEL=${CLI_ROOT_LOG_LEVEL:-"INFO"} +CLI_ROOT_LOG_APPENDER=${CLI_ROOT_LOG_APPENDER:-"CONSOLE"} # Configure the classpath CLI_CLASSPATH="$CLI_CLASSPATH:$CLI_EXTRA_CLASSPATH" @@ -49,7 +50,7 @@ CLI_CLASSPATH="`dirname $CLI_LOG_CONF`:$CLI_CLASSPATH" BOOKIE_OPTS=$(build_bookie_opts) GC_OPTS=$(build_cli_jvm_opts ${CLI_LOG_DIR} "bkperf-gc.log") NETTY_OPTS=$(build_netty_opts) -LOGGING_OPTS=$(build_cli_logging_opts ${CLI_LOG_CONF} ${CLI_LOG_DIR} ${CLI_LOG_FILE} ${CLI_ROOT_LOGGER}) +LOGGING_OPTS=$(build_cli_logging_opts ${CLI_LOG_CONF} ${CLI_ROOT_LOG_LEVEL} ${CLI_ROOT_LOG_APPENDER} ${CLI_LOG_DIR} ${CLI_LOG_FILE}) OPTS="${OPTS} -cp ${CLI_CLASSPATH} ${BOOKIE_OPTS} ${GC_OPTS} ${NETTY_OPTS} ${LOGGING_OPTS} ${CLI_EXTRA_OPTS}" diff --git a/tests/docker-images/statestore-image/bin/bookkeeper b/tests/docker-images/statestore-image/bin/bookkeeper index 55fcd72479e..5cbedc47b06 100755 --- a/tests/docker-images/statestore-image/bin/bookkeeper +++ b/tests/docker-images/statestore-image/bin/bookkeeper @@ -45,7 +45,7 @@ shift LOCALBOOKIES_CONFIG_DIR="${LOCALBOOKIES_CONFIG_DIR:-/tmp/localbookies-config}" if [ ${COMMAND} == "shell" ]; then - DEFAULT_LOG_CONF=${BK_HOME}/conf/log4j.shell.properties + DEFAULT_LOG_CONF=${BK_HOME}/conf/log4j2.shell.xml if [[ $1 == "-localbookie" ]]; then if [[ $2 == *:* ]]; then @@ -72,7 +72,8 @@ if [ -z "$BOOKIE_LOG_CONF" ]; then fi BOOKIE_LOG_DIR=${BOOKIE_LOG_DIR:-"$BK_HOME/logs"} BOOKIE_LOG_FILE=${BOOKIE_LOG_FILE:-"bookkeeper-server.log"} -BOOKIE_ROOT_LOGGER=${BOOKIE_ROOT_LOGGER:-"INFO,CONSOLE"} +BOOKIE_ROOT_LOG_LEVEL=${BOOKIE_ROOT_LOG_LEVEL:-"INFO"} +BOOKIE_ROOT_LOG_APPENDER=${BOOKIE_ROOT_LOG_APPENDER:-"CONSOLE"} # Configure the classpath BOOKIE_CLASSPATH="$BOOKIE_JAR:$BOOKIE_CLASSPATH:$BOOKIE_EXTRA_CLASSPATH" @@ -84,7 +85,7 @@ echo ${BOOKIE_LOG_CONF} BOOKIE_OPTS=$(build_bookie_opts) GC_OPTS=$(build_bookie_jvm_opts ${BOOKIE_LOG_DIR} "gc_%p.log") NETTY_OPTS=$(build_netty_opts) -LOGGING_OPTS=$(build_logging_opts ${BOOKIE_LOG_CONF} ${BOOKIE_LOG_DIR} ${BOOKIE_LOG_FILE} ${BOOKIE_ROOT_LOGGER}) +LOGGING_OPTS=$(build_logging_opts ${BOOKIE_LOG_CONF} ${BOOKIE_ROOT_LOG_LEVEL} ${BOOKIE_ROOT_LOG_APPENDER} ${BOOKIE_LOG_DIR} ${BOOKIE_LOG_FILE}) OPTS="${OPTS} -cp ${BOOKIE_CLASSPATH} ${BOOKIE_OPTS} ${GC_OPTS} ${NETTY_OPTS} ${LOGGING_OPTS} ${BOOKIE_EXTRA_OPTS}" diff --git a/tests/docker-images/statestore-image/conf/log4j.cli.properties b/tests/docker-images/statestore-image/conf/log4j.cli.properties deleted file mode 100644 index 6dcfe4c74c2..00000000000 --- a/tests/docker-images/statestore-image/conf/log4j.cli.properties +++ /dev/null @@ -1,41 +0,0 @@ -# -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# - - -log4j.rootLogger=DEBUG,CONSOLE - -# -# Log INFO level and above messages to the console -# -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.Threshold=DEBUG -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p %m%n - -# verbose console logging -log4j.appender.VERBOSECONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.VERBOSECONSOLE.Threshold=INFO -log4j.appender.VERBOSECONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.VERBOSECONSOLE.layout.ConversionPattern=%m%n - -log4j.logger.verbose=INFO,VERBOSECONSOLE -log4j.logger.org.apache.zookeeper=INFO -log4j.logger.org.apache.bookkeeper=INFO \ No newline at end of file diff --git a/tests/docker-images/statestore-image/conf/log4j.properties b/tests/docker-images/statestore-image/conf/log4j.properties deleted file mode 100644 index cb1c53e1442..00000000000 --- a/tests/docker-images/statestore-image/conf/log4j.properties +++ /dev/null @@ -1,40 +0,0 @@ -# -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# - -log4j.rootLogger=DEBUG,CONSOLE - -# -# Log INFO level and above messages to the console -# -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.Threshold=DEBUG -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p %m%n - -# verbose console logging -log4j.appender.VERBOSECONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.VERBOSECONSOLE.Threshold=INFO -log4j.appender.VERBOSECONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.VERBOSECONSOLE.layout.ConversionPattern=%m%n - -log4j.logger.verbose=INFO,VERBOSECONSOLE -log4j.logger.org.apache.zookeeper=INFO -log4j.logger.org.apache.bookkeeper=INFO \ No newline at end of file diff --git a/tests/docker-images/statestore-image/conf/log4j.shell.properties b/tests/docker-images/statestore-image/conf/log4j.shell.properties deleted file mode 100644 index 6dcfe4c74c2..00000000000 --- a/tests/docker-images/statestore-image/conf/log4j.shell.properties +++ /dev/null @@ -1,41 +0,0 @@ -# -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# - - -log4j.rootLogger=DEBUG,CONSOLE - -# -# Log INFO level and above messages to the console -# -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.Threshold=DEBUG -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p %m%n - -# verbose console logging -log4j.appender.VERBOSECONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.VERBOSECONSOLE.Threshold=INFO -log4j.appender.VERBOSECONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.VERBOSECONSOLE.layout.ConversionPattern=%m%n - -log4j.logger.verbose=INFO,VERBOSECONSOLE -log4j.logger.org.apache.zookeeper=INFO -log4j.logger.org.apache.bookkeeper=INFO \ No newline at end of file diff --git a/tests/docker-images/statestore-image/conf/log4j2.cli.xml b/tests/docker-images/statestore-image/conf/log4j2.cli.xml new file mode 100644 index 00000000000..d2617157692 --- /dev/null +++ b/tests/docker-images/statestore-image/conf/log4j2.cli.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/tests/docker-images/statestore-image/conf/log4j2.shell.xml b/tests/docker-images/statestore-image/conf/log4j2.shell.xml new file mode 100644 index 00000000000..d2617157692 --- /dev/null +++ b/tests/docker-images/statestore-image/conf/log4j2.shell.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/tests/docker-images/statestore-image/conf/log4j2.xml b/tests/docker-images/statestore-image/conf/log4j2.xml new file mode 100644 index 00000000000..d2617157692 --- /dev/null +++ b/tests/docker-images/statestore-image/conf/log4j2.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/tests/integration/cluster/build.gradle b/tests/integration/cluster/build.gradle index a8acf526144..02485122b1e 100644 --- a/tests/integration/cluster/build.gradle +++ b/tests/integration/cluster/build.gradle @@ -39,7 +39,6 @@ dependencies { testImplementation project(':testtools') testCompileOnly depLibs.lombok - testImplementation depLibs.log4j12api testImplementation depLibs.log4jCore testImplementation depLibs.testcontainers testImplementation depLibs.commonsConfiguration diff --git a/tests/scripts/src/test/bash/bk_test_bin_common.sh b/tests/scripts/src/test/bash/bk_test_bin_common.sh index f95b3dadcd3..d9efd9c435b 100644 --- a/tests/scripts/src/test/bash/bk_test_bin_common.sh +++ b/tests/scripts/src/test/bash/bk_test_bin_common.sh @@ -31,7 +31,7 @@ testDefaultVariables() { source ${BK_BINDIR}/common.sh assertEquals "BINDIR is not set correctly" "${BK_BINDIR}" "${BINDIR}" assertEquals "BK_HOME is not set correctly" "${BK_HOMEDIR}" "${BK_HOME}" - assertEquals "DEFAULT_LOG_CONF is not set correctly" "${BK_CONFDIR}/log4j.properties" "${DEFAULT_LOG_CONF}" + assertEquals "DEFAULT_LOG_CONF is not set correctly" "${BK_CONFDIR}/log4j2.xml" "${DEFAULT_LOG_CONF}" assertEquals "NETTY_LEAK_DETECTION_LEVEL is not set correctly" "disabled" "${NETTY_LEAK_DETECTION_LEVEL}" assertEquals "NETTY_RECYCLER_MAXCAPACITY is not set correctly" "1000" "${NETTY_RECYCLER_MAXCAPACITY}" assertEquals "NETTY_RECYCLER_LINKCAPACITY is not set correctly" "1024" "${NETTY_RECYCLER_LINKCAPACITY}" @@ -246,13 +246,15 @@ testBuildLoggingOpts() { TEST_CONF_FILE="test.conf" TEST_LOG_DIR="test_log_dir" TEST_LOG_FILE="test_log_file" - TEST_LOGGER="INFO,TEST" + TEST_LOG_LEVEL="INFO" + TEST_LOG_APPENDER="TEST" - EXPECTED_OPTS="-Dlog4j.configuration=${TEST_CONF_FILE} \ - -Dbookkeeper.root.logger=${TEST_LOGGER} \ + EXPECTED_OPTS="-Dlog4j.configurationFile=${TEST_CONF_FILE} \ + -Dbookkeeper.log.root.level=${TEST_LOGGER} \ + -Dbookkeeper.log.root.appender=${TEST_LOG_DIR} \ -Dbookkeeper.log.dir=${TEST_LOG_DIR} \ -Dbookkeeper.log.file=${TEST_LOG_FILE}" - ACTUAL_OPTS=$(build_logging_opts ${TEST_CONF_FILE} ${TEST_LOG_DIR} ${TEST_LOG_FILE} ${TEST_LOGGER}) + ACTUAL_OPTS=$(build_logging_opts ${TEST_CONF_FILE} ${TEST_LOG_LEVEL} ${TEST_LOG_APPENDER} ${TEST_LOG_DIR} ${TEST_LOG_FILE}) assertEquals "Logging OPTS is not set correctly" "${EXPECTED_OPTS}" "${ACTUAL_OPTS}" } @@ -263,7 +265,7 @@ testBuildCLILoggingOpts() { TEST_LOG_FILE="test_log_file" TEST_LOGGER="INFO,TEST" - EXPECTED_OPTS="-Dlog4j.configuration=${TEST_CONF_FILE} \ + EXPECTED_OPTS="-Dlog4j.configurationFile=${TEST_CONF_FILE} \ -Dbookkeeper.cli.root.logger=${TEST_LOGGER} \ -Dbookkeeper.cli.log.dir=${TEST_LOG_DIR} \ -Dbookkeeper.cli.log.file=${TEST_LOG_FILE}" diff --git a/tests/scripts/src/test/bash/gradle/bk_test_bin_common.sh b/tests/scripts/src/test/bash/gradle/bk_test_bin_common.sh index 152298bbb98..cd83b9fa1b9 100644 --- a/tests/scripts/src/test/bash/gradle/bk_test_bin_common.sh +++ b/tests/scripts/src/test/bash/gradle/bk_test_bin_common.sh @@ -30,7 +30,7 @@ testDefaultVariables() { source ${BK_BINDIR}/common_gradle.sh assertEquals "BINDIR is not set correctly" "${BK_BINDIR}" "${BINDIR}" assertEquals "BK_HOME is not set correctly" "${BK_HOMEDIR}" "${BK_HOME}" - assertEquals "DEFAULT_LOG_CONF is not set correctly" "${BK_CONFDIR}/log4j.properties" "${DEFAULT_LOG_CONF}" + assertEquals "DEFAULT_LOG_CONF is not set correctly" "${BK_CONFDIR}/log4j2.xml" "${DEFAULT_LOG_CONF}" assertEquals "NETTY_LEAK_DETECTION_LEVEL is not set correctly" "disabled" "${NETTY_LEAK_DETECTION_LEVEL}" assertEquals "NETTY_RECYCLER_MAXCAPACITY is not set correctly" "1000" "${NETTY_RECYCLER_MAXCAPACITY}" assertEquals "NETTY_RECYCLER_LINKCAPACITY is not set correctly" "1024" "${NETTY_RECYCLER_LINKCAPACITY}" @@ -225,11 +225,12 @@ testBuildLoggingOpts() { TEST_LOG_FILE="test_log_file" TEST_LOGGER="INFO,TEST" - EXPECTED_OPTS="-Dlog4j.configuration=${TEST_CONF_FILE} \ - -Dbookkeeper.root.logger=${TEST_LOGGER} \ + EXPECTED_OPTS="-Dlog4j.configurationFile=${TEST_CONF_FILE} \ + -Dbookkeeper.log.root.level=${TEST_LOGGER} \ + -Dbookkeeper.log.root.appender=${TEST_LOG_DIR} \ -Dbookkeeper.log.dir=${TEST_LOG_DIR} \ -Dbookkeeper.log.file=${TEST_LOG_FILE}" - ACTUAL_OPTS=$(build_logging_opts ${TEST_CONF_FILE} ${TEST_LOG_DIR} ${TEST_LOG_FILE} ${TEST_LOGGER}) + ACTUAL_OPTS=$(build_logging_opts ${TEST_CONF_FILE} ${TEST_LOG_LEVEL} ${TEST_LOG_APPENDER} ${TEST_LOG_DIR} ${TEST_LOG_FILE}) assertEquals "Logging OPTS is not set correctly" "${EXPECTED_OPTS}" "${ACTUAL_OPTS}" } @@ -240,7 +241,7 @@ testBuildCLILoggingOpts() { TEST_LOG_FILE="test_log_file" TEST_LOGGER="INFO,TEST" - EXPECTED_OPTS="-Dlog4j.configuration=${TEST_CONF_FILE} \ + EXPECTED_OPTS="-Dlog4j.configurationFile=${TEST_CONF_FILE} \ -Dbookkeeper.cli.root.logger=${TEST_LOGGER} \ -Dbookkeeper.cli.log.dir=${TEST_LOG_DIR} \ -Dbookkeeper.cli.log.file=${TEST_LOG_FILE}" diff --git a/tools/ledger/pom.xml b/tools/ledger/pom.xml index 0ba321a3402..748344109f8 100644 --- a/tools/ledger/pom.xml +++ b/tools/ledger/pom.xml @@ -35,11 +35,6 @@ bookkeeper-server ${project.parent.version} - - org.apache.logging.log4j - log4j-1.2-api - runtime - org.apache.logging.log4j log4j-core diff --git a/tools/perf/build.gradle b/tools/perf/build.gradle index 36d04907fe7..d22e152f9da 100644 --- a/tools/perf/build.gradle +++ b/tools/perf/build.gradle @@ -45,7 +45,6 @@ dependencies { implementation depLibs.commonsConfiguration implementation depLibs.guava implementation depLibs.jcommander - implementation depLibs.log4j12api implementation depLibs.zookeeper implementation depLibs.curatorFramework implementation depLibs.protobuf diff --git a/tools/stream/build.gradle b/tools/stream/build.gradle index 1a379216554..aa4ee9838a4 100644 --- a/tools/stream/build.gradle +++ b/tools/stream/build.gradle @@ -42,7 +42,6 @@ dependencies { implementation depLibs.commonsConfiguration implementation depLibs.guava implementation depLibs.jcommander - implementation depLibs.log4j12api implementation depLibs.zookeeper implementation depLibs.curatorFramework implementation depLibs.protobuf