Skip to content
Permalink
Browse files
Remove log4j from bookkeeper (#3225)
  • Loading branch information
Shoothzj committed Apr 22, 2022
1 parent 4011138 commit f0988ddf250440813866849cef4f734174a48fc4
Showing 66 changed files with 592 additions and 809 deletions.
@@ -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}"

@@ -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}"

@@ -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}"
@@ -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"
@@ -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}"
@@ -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}"
}
@@ -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}"
}
@@ -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"
@@ -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"

@@ -41,7 +41,6 @@ dependencies {
implementation depLibs.nettyBuffer
implementation depLibs.nettyTransportNativeEpoll
implementation depLibs.zookeeper
implementation depLibs.log4j12api
implementation depLibs.log4jCore
implementation depLibs.log4jSlf4jImpl

This file was deleted.

0 comments on commit f0988dd

Please sign in to comment.