You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by eo...@apache.org on 2022/04/22 16:10:22 UTC

[bookkeeper] branch master updated: Remove log4j from bookkeeper (#3225)

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

eolivelli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new f0988ddf2 Remove log4j from bookkeeper (#3225)
f0988ddf2 is described below

commit f0988ddf250440813866849cef4f734174a48fc4
Author: ZhangJian He <sh...@gmail.com>
AuthorDate: Sat Apr 23 00:10:18 2022 +0800

    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 -----------
 bookkeeper-server/src/main/resources/log4j2.xml    | 33 ++++++++++
 buildtools/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 -
 tests/docker-images/statestore-image/bin/bkctl     |  7 +-
 tests/docker-images/statestore-image/bin/bkperf    |  7 +-
 .../docker-images/statestore-image/bin/bookkeeper  |  7 +-
 .../statestore-image/conf/log4j.cli.properties     | 41 ------------
 .../statestore-image/conf/log4j.properties         | 40 -----------
 .../statestore-image/conf/log4j.shell.properties   | 41 ------------
 .../statestore-image/conf/log4j2.cli.xml           | 33 ++++++++++
 .../statestore-image/conf/log4j2.shell.xml         | 33 ++++++++++
 .../docker-images/statestore-image/conf/log4j2.xml | 33 ++++++++++
 tests/integration/cluster/build.gradle             |  1 -
 tests/scripts/src/test/bash/bk_test_bin_common.sh  | 14 ++--
 .../src/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(-)

diff --git a/bin/bkctl b/bin/bkctl
index ec0a0c7e7..26d3b6ece 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 857eda4d5..1cd3f71fc 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 ac409684f..cffc267cc 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 d64a4489b..621aa18e6 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 22545b29c..494907a1e 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 7949cf906..c791ef8b8 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 82d8fdb87..99ac61241 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 1e80db97b..2e8c2a32a 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 <<EOF
@@ -80,21 +80,23 @@ if [ ${COMMAND} == "local" ]; then
   DLOG_LOG_CONF=${BOOKIE_LOG_CONF:-"${DEFAULT_LOG_CONF}"}
   DLOG_LOG_DIR=${BOOKIE_LOG_DIR:-"${BK_HOME}/logs"}
   DLOG_LOG_FILE=${BOOKIE_LOG_FILE:-"dlog.log"}
-  DLOG_ROOT_LOGGER=${BOOKIE_ROOT_LOGGER:-"INFO,CONSOLE"}
+  DLOG_ROOT_LOG_LEVEL=${BOOKIE_ROOT_LOG_LEVEL:-"INFO"}
+  DLOG_ROOT_LOG_APPENDER=${BOOKIE_ROOT_LOG_APPENDER:-"CONSOLE"}
   DLOG_EXTRA_CLASSPATH=${BOOKIE_EXTRA_CLASSPATH}
   DLOG_GC_OPTS=$(build_bookie_jvm_opts ${DLOG_LOG_DIR} "dlog_gc_%p.log")
   DLOG_EXTRA_OPTS=${BOOKIE_EXTRA_OPTS}
-  DLOG_LOGGING_OPTS=$(build_logging_opts ${DLOG_LOG_CONF} ${DLOG_LOG_DIR} ${DLOG_LOG_FILE} ${DLOG_ROOT_LOGGER})
+  DLOG_LOGGING_OPTS=$(build_logging_opts ${DLOG_LOG_CONF} ${DLOG_ROOT_LOG_LEVEL} ${DLOG_ROOT_LOG_APPENDER} ${DLOG_LOG_DIR} ${DLOG_LOG_FILE})
 else
   DLOG_CONF=${CLI_CONF:-"${DEFAULT_CLI_CONF}"}
   DLOG_LOG_CONF=${CLI_LOG_CONF:-"${DEFAULT_CLI_LOG_CONF}"}
   DLOG_LOG_DIR=${CLI_LOG_DIR:-"${BK_HOME}/logs"}
   DLOG_LOG_FILE=${CLI_LOG_FILE:-"dlog-cli.log"}
-  DLOG_ROOT_LOGGER=${CLI_ROOT_LOGGER:-"INFO,ROLLINGFILE"}
+  DLOG_ROOT_LOG_LEVEL=${CLI_ROOT_LOG_LEVEL:-"INFO"}
+  DLOG_ROOT_LOG_APPENDER=${CLI_ROOT_LOG_APPENDER:-"ROLLINGFILE"}
   DLOG_EXTRA_CLASSPATH=${CLI_EXTRA_CLASSPATH}
   DLOG_GC_OPTS=$(build_cli_jvm_opts ${DLOG_LOG_DIR} "dlog-cli-gc.log")
   DLOG_EXTRA_OPTS=${CLI_EXTRA_OPTS}
-  DLOG_LOGGING_OPTS=$(build_cli_logging_opts ${DLOG_LOG_CONF} ${DLOG_LOG_DIR} ${DLOG_LOG_FILE} ${DLOG_ROOT_LOGGER})
+  DLOG_LOGGING_OPTS=$(build_cli_logging_opts ${DLOG_LOG_CONF} ${DLOG_ROOT_LOG_LEVEL} ${DLOG_ROOT_LOG_APPENDER} ${DLOG_LOG_DIR} ${DLOG_LOG_FILE})
 fi
 
 DLOG_CLASSPATH="$DLOG_JAR:$DLOG_CLASSPATH:$DLOG_EXTRA_CLASSPATH"
diff --git a/bookkeeper-benchmark/bin/benchmark b/bookkeeper-benchmark/bin/benchmark
index 3158aac14..862902a1f 100755
--- a/bookkeeper-benchmark/bin/benchmark
+++ b/bookkeeper-benchmark/bin/benchmark
@@ -61,7 +61,7 @@ use -help with individual commands for more options. For example,
 or command is the full name of a class with a defined main() method.
 
 Environment variables:
-   BENCHMARK_LOG_CONF        Log4j configuration file (default: conf/log4j.properties)
+   BENCHMARK_LOG_CONF        Log4j configuration file (default: conf/log4j2.xml)
    BENCHMARK_EXTRA_OPTS      Extra options to be passed to the jvm
    BENCHMARK_EXTRA_CLASSPATH Add extra paths to the bookkeeper classpath
 
@@ -104,11 +104,11 @@ COMMAND=$1
 shift
 
 BENCHMARK_CLASSPATH="$BENCHMARK_JAR:$BENCHMARK_CLASSPATH:$BENCHMARK_EXTRA_CLASSPATH"
-BENCHMARK_LOG_CONF=${BENCHMARK_LOG_CONF:-$BENCH_HOME/conf/log4j.properties}
+BENCHMARK_LOG_CONF=${BENCHMARK_LOG_CONF:-$BENCH_HOME/conf/log4j2.xml}
 
 if [ "$BENCHMARK_LOG_CONF" != "" ]; then
     BENCHMARK_CLASSPATH="`dirname $BENCHMARK_LOG_CONF`:$BENCHMARK_CLASSPATH"
-    OPTS="$OPTS -Dlog4j.configuration=`basename $BENCHMARK_LOG_CONF`"
+    OPTS="$OPTS -Dlog4j.configurationFile=`basename $BENCHMARK_LOG_CONF`"
 fi
 OPTS="-cp $BENCHMARK_CLASSPATH $OPTS $BENCHMARK_EXTRA_OPTS"
 
diff --git a/bookkeeper-benchmark/build.gradle b/bookkeeper-benchmark/build.gradle
index 3dec69e52..1d774e9e4 100644
--- a/bookkeeper-benchmark/build.gradle
+++ b/bookkeeper-benchmark/build.gradle
@@ -41,7 +41,6 @@ dependencies {
     implementation depLibs.nettyBuffer
     implementation depLibs.nettyTransportNativeEpoll
     implementation depLibs.zookeeper
-    implementation depLibs.log4j12api
     implementation depLibs.log4jCore
     implementation depLibs.log4jSlf4jImpl
 
diff --git a/bookkeeper-benchmark/conf/log4j.properties b/bookkeeper-benchmark/conf/log4j.properties
deleted file mode 100644
index 4a0f5e107..000000000
--- a/bookkeeper-benchmark/conf/log4j.properties
+++ /dev/null
@@ -1,69 +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 threshold> (, <appender>)+
-
-# 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 000000000..21257d6dc
--- /dev/null
+++ b/bookkeeper-benchmark/conf/log4j2.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<Configuration status="warn" monitorInterval="10">
+    <Appenders>
+        <Console name="CONSOLE" target="SYSTEM_OUT">
+            <PatternLayout pattern="%d{ISO8601} - %-5p - [%t:%C{1}@%L] - %m%n"/>
+        </Console>
+        <File name="TRACEFILE" fileName="bookkeeper_trace.log">
+            <PatternLayout pattern="%d{ISO8601} - %-5p [%t:%C{1}@%L][%ndc] - %m%n"/>
+        </File>
+        <RollingFile name="ROLLINGFILE" fileName="bookkeeper-benchmark.log" filePattern="bookkeeper-benchmark.log%d{.yyyy-MM-dd}">
+            <PatternLayout pattern="%d{ISO8601} - %-5p - [%t:%C{1}@%L] - %m%n"/>
+            <Policies>
+                <TimeBasedTriggeringPolicy modulate="true"/>
+            </Policies>
+            <DefaultRolloverStrategy max="100"/>
+        </RollingFile>
+    </Appenders>
+    <Loggers>
+        <Root level="ERROR">
+            <AppenderRef ref="CONSOLE"/>
+        </Root>
+        <Logger name="org.apache.bookkeeper.benchmark" level="INFO"/>
+    </Loggers>
+</Configuration>
diff --git a/bookkeeper-common/pom.xml b/bookkeeper-common/pom.xml
index c88a002f8..5667c3809 100644
--- a/bookkeeper-common/pom.xml
+++ b/bookkeeper-common/pom.xml
@@ -85,18 +85,6 @@
       <artifactId>commons-lang3</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-core</artifactId>
-      <version>${log4j.version}</version>
-      <scope>test</scope> <!-- There are tests that rely on this binding in their test logic -->
-    </dependency>
-    <dependency>
-      <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-slf4j-impl</artifactId>
-      <version>${log4j.version}</version>
-      <scope>test</scope> <!-- There are tests that rely on this binding in their test logic -->
-    </dependency>
   </dependencies>
   <build>
     <plugins>
diff --git a/bookkeeper-dist/all/build.gradle b/bookkeeper-dist/all/build.gradle
index 486eede5a..523718e46 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 2fb45d749..b9ddb97a9 100644
--- a/bookkeeper-dist/all/pom.xml
+++ b/bookkeeper-dist/all/pom.xml
@@ -103,20 +103,6 @@
       <version>${project.version}</version>
     </dependency>
 
-    <!-- slf4j binding -->
-    <dependency>
-      <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-1.2-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-core</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-slf4j-impl</artifactId>
-    </dependency>
-
     <dependency>
        <!-- needed by ZooKeeper server -->
        <groupId>org.xerial.snappy</groupId>
diff --git a/bookkeeper-dist/bkctl/build.gradle b/bookkeeper-dist/bkctl/build.gradle
index 23a4aa078..c2e9d41dc 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 dc40b6e4d..f26e8b0b6 100644
--- a/bookkeeper-dist/bkctl/pom.xml
+++ b/bookkeeper-dist/bkctl/pom.xml
@@ -44,20 +44,6 @@
         </exclusion>
       </exclusions>
     </dependency>
-
-    <!-- slf4j binding -->
-    <dependency>
-      <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-1.2-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-core</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-slf4j-impl</artifactId>
-    </dependency>
   </dependencies>
 
   <build>
diff --git a/bookkeeper-dist/server/build.gradle b/bookkeeper-dist/server/build.gradle
index 752bccf0e..0c1540e7f 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 6c61b3637..b9fc5de8c 100644
--- a/bookkeeper-dist/server/pom.xml
+++ b/bookkeeper-dist/server/pom.xml
@@ -83,20 +83,6 @@
       <version>${project.version}</version>
     </dependency>
 
-    <!-- slf4j binding -->
-    <dependency>
-      <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-1.2-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-core</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-slf4j-impl</artifactId>
-    </dependency>
-
     <dependency>
        <!-- needed by ZooKeeper server -->
        <groupId>org.xerial.snappy</groupId>
diff --git a/bookkeeper-dist/src/assemble/bkctl.xml b/bookkeeper-dist/src/assemble/bkctl.xml
index 6308ecb10..718a9c856 100644
--- a/bookkeeper-dist/src/assemble/bkctl.xml
+++ b/bookkeeper-dist/src/assemble/bkctl.xml
@@ -38,8 +38,8 @@
         <include>bk_server.conf</include>
         <include>bkenv.sh</include>
         <include>jaas_example.conf</include>
-        <include>log4j.cli.properties</include>
-        <include>log4j.shell.properties</include>
+        <include>log4j2.cli.xml</include>
+        <include>log4j2.shell.xml</include>
         <include>nettyenv.sh</include>
         <include>default_rocksdb.conf</include>
         <include>entry_location_rocksdb.conf</include>
diff --git a/bookkeeper-dist/src/main/resources/LICENSE-all.bin.txt b/bookkeeper-dist/src/main/resources/LICENSE-all.bin.txt
index ab3807615..2dabc1fa3 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 b803f539e..d4759c535 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 dc419e532..8539216fe 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 b51615c58..bc7886d7b 100644
--- a/bookkeeper-server/pom.xml
+++ b/bookkeeper-server/pom.xml
@@ -55,18 +55,6 @@
       <version>${project.parent.version}</version>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-core</artifactId>
-      <version>${log4j.version}</version>
-      <scope>test</scope> <!-- There are tests that rely on this binding in their test logic -->
-    </dependency>
-    <dependency>
-      <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-slf4j-impl</artifactId>
-      <version>${log4j.version}</version>
-      <scope>test</scope> <!-- There are tests that rely on this binding in their test logic -->
-    </dependency>
     <dependency>
       <groupId>org.apache.zookeeper</groupId>
       <artifactId>zookeeper</artifactId>
diff --git a/bookkeeper-server/src/main/resources/log4j.properties b/bookkeeper-server/src/main/resources/log4j.properties
deleted file mode 100644
index 7703c575b..000000000
--- 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 threshold> (, <appender>)+
-
-# 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 000000000..3e3e4bc8c
--- /dev/null
+++ b/bookkeeper-server/src/main/resources/log4j2.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<Configuration status="warn" monitorInterval="10">
+    <Appenders>
+        <Console name="CONSOLE" target="SYSTEM_OUT">
+            <PatternLayout pattern="%d{ISO8601} - %-5p - [%t:%C{1}@%L] - %m%n"/>
+        </Console>
+    </Appenders>
+    <Loggers>
+        <Root level="INFO">
+            <AppenderRef ref="CONSOLE"/>
+        </Root>
+    </Loggers>
+</Configuration>
diff --git a/buildtools/src/main/resources/log4j.properties b/buildtools/src/main/resources/log4j.properties
deleted file mode 100644
index 10ae6bfcb..000000000
--- 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 threshold> (, <appender>)+
-
-# 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 000000000..050035d80
--- /dev/null
+++ b/buildtools/src/main/resources/log4j2.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<Configuration status="warn" monitorInterval="10">
+    <Appenders>
+        <Console name="CONSOLE" target="SYSTEM_OUT">
+            <PatternLayout pattern="%d{ISO8601} - %-5p - [%t:%C{1}@%L] - %m%n"/>
+        </Console>
+    </Appenders>
+    <Loggers>
+        <Root level="INFO">
+            <AppenderRef ref="CONSOLE"/>
+        </Root>
+        <Logger name="org.apache.zookeeper" level="WARN" additivty="false">
+            <AppenderRef ref="CONSOLE"/>
+        </Logger>
+    </Loggers>
+</Configuration>
diff --git a/conf/bk_cli_env.sh b/conf/bk_cli_env.sh
index 8faa03d36..dde6c4b31 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 f6d061611..570e0c6f4 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 a57503349..000000000
--- 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 cee7364bc..000000000
--- 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 threshold> (, <appender>)+
-
-# 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 32b963e35..000000000
--- 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 000000000..3a1d2fa4f
--- /dev/null
+++ b/conf/log4j2.cli.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<Configuration status="warn" monitorInterval="10">
+    <Properties>
+        <Property name="bookkeeper.cli.log.dir">.</Property>
+        <Property name="bookkeeper.cli.log.file">bookkeeper-server.log</Property>
+        <Property name="bookkeeper.cli.log.root.level">INFO</Property>
+        <Property name="bookkeeper.cli.log.root.appender">CONSOLE</Property>
+    </Properties>
+    <Appenders>
+        <Console name="CONSOLE" target="SYSTEM_OUT">
+            <PatternLayout pattern="%d{ABSOLUTE} %-5p %m%n"/>
+        </Console>
+        <Console name="VERBOSECONSOLE" target="SYSTEM_OUT">
+            <PatternLayout pattern="%m%n"/>
+        </Console>
+        <RollingFile name="ROLLINGFILE" fileName="${sys:bookkeeper.cli.log.dir}/${sys:bookkeeper.cli.log.file}" filePattern="${sys:bookkeeper.cli.log.dir}/${sys:bookkeeper.cli.log.file}%d{.yyyy-MM-dd}">
+            <PatternLayout pattern="%d{ISO8601} - %-5p - [%t:%C{1}@%L] - %m%n"/>
+            <Policies>
+                <TimeBasedTriggeringPolicy modulate="true"/>
+            </Policies>
+            <DefaultRolloverStrategy max="100"/>
+        </RollingFile>
+    </Appenders>
+    <Loggers>
+        <Root level="${sys:bookkeeper.cli.log.root.level}">
+            <AppenderRef ref="${sys:bookkeeper.cli.log.root.appender}"/>
+        </Root>
+        <Logger name="org.apache.zookeeper" level="ERROR"/>
+        <Logger name="verbose" level="INFO">
+            <AppenderRef ref="VERBOSECONSOLE"/>
+        </Logger>
+    </Loggers>
+</Configuration>
diff --git a/conf/log4j2.shell.xml b/conf/log4j2.shell.xml
new file mode 100644
index 000000000..7c15d5d6c
--- /dev/null
+++ b/conf/log4j2.shell.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<Configuration status="warn" monitorInterval="10">
+    <Properties>
+        <Property name="bookkeeper.log.root.level">INFO</Property>
+        <Property name="bookkeeper.log.root.appender">CONSOLE</Property>
+    </Properties>
+    <Appenders>
+        <Console name="CONSOLE" target="SYSTEM_OUT">
+            <PatternLayout pattern="%d{ABSOLUTE} %-5p %m%n"/>
+        </Console>
+    </Appenders>
+    <Loggers>
+        <Root level="${sys:bookkeeper.log.root.level}">
+            <AppenderRef ref="${sys:bookkeeper.log.root.appender}"/>
+        </Root>
+        <Logger name="org.apache.zookeeper" level="INFO"/>
+        <Logger name="org.apache.bookkeeper.bookie.BookieShell" level="INFO"/>
+        <Logger name="org.apache.bookkeeper.bookie.InterleavedStorageRegenerateIndexOp" level="INFO"/>
+        <Logger name="org.apache.bookkeeper.client.BookKeeperAdmin" level="INFO"/>
+        <Logger name="org.apache.bookkeeper.tools.cli.commands.bookies.InstanceIdCommand" level="INFO"/>
+        <Logger name="org.apache.bookkeeper" level="INFO"/>
+    </Loggers>
+</Configuration>
diff --git a/conf/log4j2.xml b/conf/log4j2.xml
new file mode 100644
index 000000000..61c92a593
--- /dev/null
+++ b/conf/log4j2.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<Configuration status="warn" monitorInterval="10">
+    <Properties>
+        <Property name="bookkeeper.log.dir">.</Property>
+        <Property name="bookkeeper.log.file">bookkeeper-server.log</Property>
+        <Property name="bookkeeper.log.root.level">INFO</Property>
+        <Property name="bookkeeper.log.root.appender">CONSOLE</Property>
+    </Properties>
+    <Appenders>
+        <Console name="CONSOLE" target="SYSTEM_OUT">
+            <PatternLayout pattern="%d{ISO8601} - %-5p - [%t:%C{1}@%L] - %m%n"/>
+        </Console>
+        <File name="TRACEFILE" fileName="${sys:bookkeeper.log.dir}/bookkeeper-trace.log">
+            <PatternLayout pattern="%d{ISO8601} - %-5p [%t:%C{1}@%L][%ndc] - %m%n"/>
+        </File>
+        <RollingFile name="ROLLINGFILE" fileName="${sys:bookkeeper.log.dir}/${sys:bookkeeper.log.file}" filePattern="${sys:bookkeeper.log.dir}/${sys:bookkeeper.log.file}%d{.yyyy-MM-dd}">
+            <PatternLayout pattern="%d{ISO8601} - %-5p [%t:%C{1}@%L] - %m%n"/>
+            <Policies>
+                <TimeBasedTriggeringPolicy modulate="true"/>
+            </Policies>
+            <DefaultRolloverStrategy max="100"/>
+        </RollingFile>
+    </Appenders>
+    <Loggers>
+        <Root level="${sys:bookkeeper.log.root.level}">
+            <AppenderRef ref="${sys:bookkeeper.log.root.appender}"/>
+        </Root>
+    </Loggers>
+</Configuration>
diff --git a/dependencies.gradle b/dependencies.gradle
index e3737800c..517eb0661 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 3a20aef8a..ae8969fad 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 b15d90519..4bb3c782d 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 746421cfc..43096e972 100644
--- a/microbenchmarks/pom.xml
+++ b/microbenchmarks/pom.xml
@@ -38,18 +38,6 @@
       <artifactId>jmh-generator-annprocess</artifactId>
       <scope>provided</scope>
     </dependency>
-    <dependency>
-      <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-1.2-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-core</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-slf4j-impl</artifactId>
-    </dependency>
     <dependency>
       <groupId>org.apache.bookkeeper</groupId>
       <artifactId>bookkeeper-server</artifactId>
diff --git a/pom.xml b/pom.xml
index 886a0c1d4..6cce137fc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -253,11 +253,6 @@
         <artifactId>slf4j-api</artifactId>
         <version>${slf4j.version}</version>
       </dependency>
-      <dependency>
-        <groupId>org.apache.logging.log4j</groupId>
-        <artifactId>log4j-1.2-api</artifactId>
-        <version>${log4j.version}</version>
-      </dependency>
       <dependency>
         <groupId>org.apache.logging.log4j</groupId>
         <artifactId>log4j-core</artifactId>
@@ -795,6 +790,14 @@
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+    </dependency>
     <dependency>
       <groupId>commons-configuration</groupId>
       <artifactId>commons-configuration</artifactId>
@@ -810,16 +813,6 @@
       <artifactId>hamcrest-all</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-core</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-slf4j-impl</artifactId>
-      <scope>test</scope>
-    </dependency>
     <dependency>
       <groupId>org.mockito</groupId>
       <artifactId>mockito-core</artifactId>
@@ -1189,7 +1182,7 @@
             <artifactId>maven-surefire-plugin</artifactId>
             <version>${maven-surefire-plugin.version}</version>
             <configuration>
-              <argLine>-Xmx2G -Djava.net.preferIPv4Stack=true -Dbookkeeper.root.logger=DEBUG,CONSOLE</argLine>
+              <argLine>-Xmx2G -Djava.net.preferIPv4Stack=true -Dbookkeeper.log.root.level=INFO -Dbookkeeper.log.root.appender=CONSOLE</argLine>
               <redirectTestOutputToFile>false</redirectTestOutputToFile>
               <forkCount>${forkCount.variable}</forkCount>
               <reuseForks>false</reuseForks>
diff --git a/site/_data/cli/bookkeeper.yaml b/site/_data/cli/bookkeeper.yaml
index fd780f151..37c62804a 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 418c4ca1b..35f629c84 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 3aee1fe37..b9b1d6ad7 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 a85c6e70d..b0877789b 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 6a1df7810..b34530401 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 27f898fad..000000000
--- 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 threshold> (, <appender>)+
-
-# 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 d6c14acdd..000000000
--- 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 threshold> (, <appender>)+
-
-# 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 000000000..8c6250139
--- /dev/null
+++ b/stream/conf/log4j2.cli.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<Configuration status="warn" monitorInterval="10">
+    <Properties>
+        <Property name="streamstorage.log.dir">logs</Property>
+        <Property name="streamstorage.log.file">stream-storage-cli.log</Property>
+        <Property name="streamstorage.log.root.level">INFO</Property>
+        <Property name="streamstorage.log.root.appender">CONSOLE</Property>
+    </Properties>
+    <Appenders>
+        <Console name="CONSOLE" target="SYSTEM_OUT">
+            <PatternLayout pattern="%d{ISO8601} - %-5p - [%t:%C{1}@%L] - %m%n"/>
+        </Console>
+        <File name="TRACEFILE" fileName="${sys:streamstorage.log.dir}/streamstorage-trace.log">
+            <PatternLayout pattern="%d{ISO8601} - %-5p [%t:%C{1}@%L][%ndc] - %m%n"/>
+        </File>
+        <RollingFile name="ROLLINGFILE" fileName="${sys:streamstorage.log.dir}/${sys:streamstorage.log.file}" filePattern="${sys:streamstorage.log.dir}/${sys:streamstorage.log.file}%d{.yyyy-MM-dd}">
+            <PatternLayout pattern="%d{ISO8601} - %-5p [%t:%C{1}@%L] - %m%n"/>
+            <Policies>
+                <TimeBasedTriggeringPolicy modulate="true"/>
+            </Policies>
+            <DefaultRolloverStrategy max="100"/>
+        </RollingFile>
+    </Appenders>
+    <Loggers>
+        <Root level="${sys:streamstorage.log.root.level}">
+            <AppenderRef ref="${sys:streamstorage.log.root.appender}"/>
+        </Root>
+    </Loggers>
+</Configuration>
diff --git a/stream/conf/log4j2.xml b/stream/conf/log4j2.xml
new file mode 100644
index 000000000..006e4bf69
--- /dev/null
+++ b/stream/conf/log4j2.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<Configuration status="warn" monitorInterval="10">
+    <Properties>
+        <Property name="streamstorage.log.dir">logs</Property>
+        <Property name="streamstorage.log.file">stream-storage.log</Property>
+        <Property name="streamstorage.log.root.level">INFO</Property>
+        <Property name="streamstorage.log.root.appender">CONSOLE</Property>
+    </Properties>
+    <Appenders>
+        <Console name="CONSOLE" target="SYSTEM_OUT">
+            <PatternLayout pattern="%d{ISO8601} - %-5p - [%t:%C{1}@%L] - %m%n"/>
+        </Console>
+        <File name="TRACEFILE" fileName="${sys:streamstorage.log.dir}/streamstorage-trace.log">
+            <PatternLayout pattern="%d{ISO8601} - %-5p [%t:%C{1}@%L][%ndc] - %m%n"/>
+        </File>
+        <RollingFile name="ROLLINGFILE" fileName="${sys:streamstorage.log.dir}/${sys:streamstorage.log.file}" filePattern="${sys:streamstorage.log.dir}/${sys:streamstorage.log.file}%d{.yyyy-MM-dd}">
+            <PatternLayout pattern="%d{ISO8601} - %-5p [%t:%C{1}@%L] - %m%n"/>
+            <Policies>
+                <TimeBasedTriggeringPolicy modulate="true"/>
+            </Policies>
+            <DefaultRolloverStrategy max="100"/>
+        </RollingFile>
+    </Appenders>
+    <Loggers>
+        <Root level="${sys:streamstorage.log.root.level}">
+            <AppenderRef ref="${sys:streamstorage.log.root.appender}"/>
+        </Root>
+    </Loggers>
+</Configuration>
diff --git a/stream/server/build.gradle b/stream/server/build.gradle
index edf934347..163cbd3f2 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 139186a06..77c917c7e 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 0bfba831b..6d6501c64 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 55fcd7247..5cbedc47b 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 6dcfe4c74..000000000
--- 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 cb1c53e14..000000000
--- 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 6dcfe4c74..000000000
--- 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 000000000..d26171576
--- /dev/null
+++ b/tests/docker-images/statestore-image/conf/log4j2.cli.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<Configuration status="warn" monitorInterval="10">
+    <Appenders>
+        <Console name="CONSOLE" target="SYSTEM_OUT">
+            <PatternLayout pattern="%m%n"/>
+        </Console>
+    </Appenders>
+    <Loggers>
+        <Root level="INFO">
+            <AppenderRef ref="CONSOLE"/>
+        </Root>
+    </Loggers>
+</Configuration>
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 000000000..d26171576
--- /dev/null
+++ b/tests/docker-images/statestore-image/conf/log4j2.shell.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<Configuration status="warn" monitorInterval="10">
+    <Appenders>
+        <Console name="CONSOLE" target="SYSTEM_OUT">
+            <PatternLayout pattern="%m%n"/>
+        </Console>
+    </Appenders>
+    <Loggers>
+        <Root level="INFO">
+            <AppenderRef ref="CONSOLE"/>
+        </Root>
+    </Loggers>
+</Configuration>
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 000000000..d26171576
--- /dev/null
+++ b/tests/docker-images/statestore-image/conf/log4j2.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<Configuration status="warn" monitorInterval="10">
+    <Appenders>
+        <Console name="CONSOLE" target="SYSTEM_OUT">
+            <PatternLayout pattern="%m%n"/>
+        </Console>
+    </Appenders>
+    <Loggers>
+        <Root level="INFO">
+            <AppenderRef ref="CONSOLE"/>
+        </Root>
+    </Loggers>
+</Configuration>
diff --git a/tests/integration/cluster/build.gradle b/tests/integration/cluster/build.gradle
index a8acf5261..02485122b 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 f95b3dadc..d9efd9c43 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 152298bbb..cd83b9fa1 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 0ba321a34..748344109 100644
--- a/tools/ledger/pom.xml
+++ b/tools/ledger/pom.xml
@@ -35,11 +35,6 @@
       <artifactId>bookkeeper-server</artifactId>
       <version>${project.parent.version}</version>
     </dependency>
-    <dependency>
-      <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-1.2-api</artifactId>
-      <scope>runtime</scope>
-    </dependency>
     <dependency>
       <groupId>org.apache.logging.log4j</groupId>
       <artifactId>log4j-core</artifactId>
diff --git a/tools/perf/build.gradle b/tools/perf/build.gradle
index 36d04907f..d22e152f9 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 1a3792165..aa4ee9838 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