Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

ZOOKEEPER-4427 Migrate to Logback #1793

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
cca424c
ZOOKEEPER-4427. Add logback dependency, fixed some unit tests, logbac…
anmolnar Dec 16, 2021
c37074d
ZOOKEEPER-4427. Logback.xml for main project
anmolnar Jan 5, 2022
7d5f936
ZOOKEEPER-4427. Add logback.xml to other resource folders
anmolnar Jan 5, 2022
86c485a
ZOOKEEPER-4427. Fix unit tests
anmolnar Jan 5, 2022
53a8205
ZOOKEEPER-4427. More unit tests fixed
anmolnar Jan 5, 2022
d594d72
ZOOKEEPER-4427. Indentation fix
anmolnar Jan 5, 2022
93e6893
ZOOKEEPER-4427. Removed log4j.properties files
anmolnar Jan 5, 2022
c74594a
ZOOKEEPER-4427. Add back log4j dependencies for contrib projects
anmolnar Jan 5, 2022
3f928ab
ZOOKEEPER-4427. Checkstyle fixes
anmolnar Jan 6, 2022
727c837
ZOOKEEPER-4427. Address cnauroth's comments
anmolnar Jan 6, 2022
953d081
ZOOKEEPER-4427. Remove root logger config from shell scripts
anmolnar Jan 18, 2022
d485248
ZOOKEEPER-4427. Added (comment) logback JMX configurator to logback.xml
anmolnar Jan 18, 2022
2ca6c20
ZOOKEEPER-4427. Remove log4j1 OWASP suppressions
anmolnar Jan 18, 2022
9c65a5e
ZOOKEEPER-4427. Docs changes
anmolnar Jan 19, 2022
0eadec1
ZOOKEEPER-4427. Update lincense and notice files
anmolnar Jan 19, 2022
b13715f
ZOOKEEPER-4427. Fix doc link
anmolnar Jan 19, 2022
26ca9ad
ZOOKEEPER-4427. Replace log4j1 license with logback's
anmolnar Jan 19, 2022
ed26105
ZOOKEEPER-4427. Remove EPL from top level LICENSE/NOTICE files
anmolnar Jan 20, 2022
8cb22fa
ZOOKEEPER-4427. Fix minor log4j references
anmolnar Jan 20, 2022
70714c0
ZOOKEEPER-4427. Use shorter version number for SLF4j
anmolnar Jan 26, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/zkCleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ ZOO_LOG_FILE=zookeeper-$USER-cleanup-$HOSTNAME.log

if [ "x$ZOODATALOGDIR" = "x" ]
then
"$JAVA" "-Dzookeeper.log.dir=${ZOO_LOG_DIR}" "-Dzookeeper.root.logger=${ZOO_LOG4J_PROP}" "-Dzookeeper.log.file=${ZOO_LOG_FILE}" \
"$JAVA" "-Dzookeeper.log.dir=${ZOO_LOG_DIR}" "-Dzookeeper.log.file=${ZOO_LOG_FILE}" \
-cp "$CLASSPATH" $JVMFLAGS \
org.apache.zookeeper.server.PurgeTxnLog "$ZOODATADIR" $*
else
"$JAVA" "-Dzookeeper.log.dir=${ZOO_LOG_DIR}" "-Dzookeeper.root.logger=${ZOO_LOG4J_PROP}" "-Dzookeeper.log.file=${ZOO_LOG_FILE}" \
"$JAVA" "-Dzookeeper.log.dir=${ZOO_LOG_DIR}" "-Dzookeeper.log.file=${ZOO_LOG_FILE}" \
-cp "$CLASSPATH" $JVMFLAGS \
org.apache.zookeeper.server.PurgeTxnLog "$ZOODATALOGDIR" "$ZOODATADIR" $*
fi
2 changes: 1 addition & 1 deletion bin/zkCli.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ call "%~dp0zkEnv.cmd"
set ZOO_LOG_FILE=zookeeper-%USERNAME%-cli-%COMPUTERNAME%.log

set ZOOMAIN=org.apache.zookeeper.ZooKeeperMain
call %JAVA% "-Dzookeeper.log.dir=%ZOO_LOG_DIR%" "-Dzookeeper.root.logger=%ZOO_LOG4J_PROP%" "-Dzookeeper.log.file=%ZOO_LOG_FILE%" -cp "%CLASSPATH%" %ZOOMAIN% %*
call %JAVA% "-Dzookeeper.log.dir=%ZOO_LOG_DIR%" "-Dzookeeper.log.file=%ZOO_LOG_FILE%" -cp "%CLASSPATH%" %ZOOMAIN% %*

endlocal

2 changes: 1 addition & 1 deletion bin/zkCli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ fi

ZOO_LOG_FILE=zookeeper-$USER-cli-$HOSTNAME.log

"$JAVA" "-Dzookeeper.log.dir=${ZOO_LOG_DIR}" "-Dzookeeper.root.logger=${ZOO_LOG4J_PROP}" "-Dzookeeper.log.file=${ZOO_LOG_FILE}" \
"$JAVA" "-Dzookeeper.log.dir=${ZOO_LOG_DIR}" "-Dzookeeper.log.file=${ZOO_LOG_FILE}" \
-cp "$CLASSPATH" $CLIENT_JVMFLAGS $JVMFLAGS \
org.apache.zookeeper.ZooKeeperMain "$@"
1 change: 0 additions & 1 deletion bin/zkEnv.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ REM limitations under the License.

set ZOOCFGDIR=%~dp0%..\conf
set ZOO_LOG_DIR=%~dp0%..\logs
set ZOO_LOG4J_PROP=INFO,CONSOLE

REM for sanity sake assume Java 1.6
REM see: http://java.sun.com/javase/6/docs/technotes/tools/windows/java.html
Expand Down
5 changes: 0 additions & 5 deletions bin/zkEnv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ then
ZOO_LOG_DIR="$ZOOKEEPER_PREFIX/logs"
fi

if [ "x${ZOO_LOG4J_PROP}" = "x" ]
then
ZOO_LOG4J_PROP="INFO,CONSOLE"
fi

if [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then
JAVA="$JAVA_HOME/bin/java"
elif type -p java; then
Expand Down
2 changes: 1 addition & 1 deletion bin/zkServer.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ set ZOOMAIN=org.apache.zookeeper.server.quorum.QuorumPeerMain
set ZOO_LOG_FILE=zookeeper-%USERNAME%-server-%COMPUTERNAME%.log

echo on
call %JAVA% "-Dzookeeper.log.dir=%ZOO_LOG_DIR%" "-Dzookeeper.root.logger=%ZOO_LOG4J_PROP%" "-Dzookeeper.log.file=%ZOO_LOG_FILE%" "-XX:+HeapDumpOnOutOfMemoryError" "-XX:OnOutOfMemoryError=cmd /c taskkill /pid %%%%p /t /f" -cp "%CLASSPATH%" %ZOOMAIN% "%ZOOCFG%" %*
call %JAVA% "-Dzookeeper.log.dir=%ZOO_LOG_DIR%" "-Dzookeeper.log.file=%ZOO_LOG_FILE%" "-XX:+HeapDumpOnOutOfMemoryError" "-XX:OnOutOfMemoryError=cmd /c taskkill /pid %%%%p /t /f" -cp "%CLASSPATH%" %ZOOMAIN% "%ZOOCFG%" %*

endlocal
8 changes: 4 additions & 4 deletions bin/zkServer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ start)
fi
fi
nohup "$JAVA" $ZOO_DATADIR_AUTOCREATE "-Dzookeeper.log.dir=${ZOO_LOG_DIR}" \
"-Dzookeeper.log.file=${ZOO_LOG_FILE}" "-Dzookeeper.root.logger=${ZOO_LOG4J_PROP}" \
"-Dzookeeper.log.file=${ZOO_LOG_FILE}" \
-XX:+HeapDumpOnOutOfMemoryError -XX:OnOutOfMemoryError='kill -9 %p' \
-cp "$CLASSPATH" $JVMFLAGS $ZOOMAIN "$ZOOCFG" > "$_ZOO_DAEMON_OUT" 2>&1 < /dev/null &
if [ $? -eq 0 ]
Expand Down Expand Up @@ -200,13 +200,13 @@ start-foreground)
ZOO_CMD=("$JAVA")
fi
"${ZOO_CMD[@]}" $ZOO_DATADIR_AUTOCREATE "-Dzookeeper.log.dir=${ZOO_LOG_DIR}" \
"-Dzookeeper.log.file=${ZOO_LOG_FILE}" "-Dzookeeper.root.logger=${ZOO_LOG4J_PROP}" \
"-Dzookeeper.log.file=${ZOO_LOG_FILE}" \
-XX:+HeapDumpOnOutOfMemoryError -XX:OnOutOfMemoryError='kill -9 %p' \
-cp "$CLASSPATH" $JVMFLAGS $ZOOMAIN "$ZOOCFG"
;;
print-cmd)
echo "\"$JAVA\" $ZOO_DATADIR_AUTOCREATE -Dzookeeper.log.dir=\"${ZOO_LOG_DIR}\" \
-Dzookeeper.log.file=\"${ZOO_LOG_FILE}\" -Dzookeeper.root.logger=\"${ZOO_LOG4J_PROP}\" \
-Dzookeeper.log.file=\"${ZOO_LOG_FILE}\" \
-XX:+HeapDumpOnOutOfMemoryError -XX:OnOutOfMemoryError='kill -9 %p' \
-cp \"$CLASSPATH\" $JVMFLAGS $ZOOMAIN \"$ZOOCFG\" > \"$_ZOO_DAEMON_OUT\" 2>&1 < /dev/null"
;;
Expand Down Expand Up @@ -287,7 +287,7 @@ status)
fi
fi
echo "Client port found: $clientPort. Client address: $clientPortAddress. Client SSL: $isSSL."
STAT=`"$JAVA" "-Dzookeeper.log.dir=${ZOO_LOG_DIR}" "-Dzookeeper.root.logger=${ZOO_LOG4J_PROP}" "-Dzookeeper.log.file=${ZOO_LOG_FILE}" \
STAT=`"$JAVA" "-Dzookeeper.log.dir=${ZOO_LOG_DIR}" "-Dzookeeper.log.file=${ZOO_LOG_FILE}" \
-cp "$CLASSPATH" $CLIENT_JVMFLAGS $JVMFLAGS org.apache.zookeeper.client.FourLetterWordMain \
$clientPortAddress $clientPort srvr $isSSL 2> /dev/null \
| $GREP Mode`
Expand Down
82 changes: 0 additions & 82 deletions conf/log4j.properties

This file was deleted.

114 changes: 114 additions & 0 deletions conf/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<!--
Copyright 2022 The Apache Software Foundation

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.

Define some default values that can be overridden by system properties
-->
<configuration>
<!-- Uncomment this if you would like to expose Logback JMX beans -->
<!--jmxConfigurator /-->

<property name="zookeeper.console.threshold" value="INFO" />

<property name="zookeeper.log.dir" value="." />
<property name="zookeeper.log.file" value="zookeeper.log" />
<property name="zookeeper.log.threshold" value="INFO" />
<property name="zookeeper.log.maxfilesize" value="256MB" />
<property name="zookeeper.log.maxbackupindex" value="20" />

<!--
console
Add "console" to root logger if you want to use this
-->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>${zookeeper.console.threshold}</level>
</filter>
</appender>

<!--
Add ROLLINGFILE to root logger to get log file output
-->
<!--appender name="ROLLINGFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${zookeeper.log.dir}/${zookeeper.log.file}</File>
<encoder>
<pattern>%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>${zookeeper.log.threshold}</level>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<maxIndex>${zookeeper.log.maxbackupindex}</maxIndex>
<FileNamePattern>${zookeeper.log.dir}/${zookeeper.log.file}.%i</FileNamePattern>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>${zookeeper.log.maxfilesize}</MaxFileSize>
</triggeringPolicy>
</appender-->

<!--
Add TRACEFILE to root logger to get log file output
Log TRACE level and above messages to a log file
-->
<!--property name="zookeeper.tracelog.dir" value="${zookeeper.log.dir}" />
<property name="zookeeper.tracelog.file" value="zookeeper_trace.log" />
<appender name="TRACEFILE" class="ch.qos.logback.core.FileAppender">
<File>${zookeeper.tracelog.dir}/${zookeeper.tracelog.file}</File>
<encoder>
<pattern>%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>TRACE</level>
</filter>
</appender-->

<!--
zk audit logging
-->
<!--property name="zookeeper.auditlog.file" value="zookeeper_audit.log" />
<property name="zookeeper.auditlog.threshold" value="INFO" />
<property name="audit.logger" value="INFO, RFAAUDIT" />

<appender name="RFAAUDIT" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${zookeeper.log.dir}/${zookeeper.auditlog.file}</File>
<encoder>
<pattern>%d{ISO8601} %p %c{2}: %m%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>${zookeeper.auditlog.threshold}</level>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<maxIndex>10</maxIndex>
<FileNamePattern>${zookeeper.log.dir}/${zookeeper.auditlog.file}.%i</FileNamePattern>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>10MB</MaxFileSize>
</triggeringPolicy>
</appender>

<logger name="org.apache.zookeeper.audit.Slf4jAuditLogger" additivity="false" level="${audit.logger}">
<appender-ref ref="RFAAUDIT" />
</logger-->

<root level="INFO">
<appender-ref ref="CONSOLE" />
</root>
</configuration>
10 changes: 0 additions & 10 deletions owaspSuppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,4 @@
this writing -->
<cve>CVE-2019-3826</cve>
</suppress>
<suppress>
<!-- false positive for us, it is about log4j server in log4j-1.2.17.jar
ZOOKEEPER-3677 -->
<cve>CVE-2019-17571</cve>
</suppress>
<suppress>
<!-- it only affects the log4j SmtpAppender users. As Log4J 1.2 is EOL now, we can't fix this unless we
upgrade to log4j 2. See ZOOKEEPER-3817 -->
<cve>CVE-2020-9488</cve>
</suppress>
</suppressions>
11 changes: 11 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@

<!-- dependency versions -->
<slf4j.version>1.7.30</slf4j.version>
<logback-version>1.2.10</logback-version>
<audience-annotations.version>0.12.0</audience-annotations.version>
<jmockit.version>1.48</jmockit.version>
<junit.version>5.6.2</junit.version>
Expand Down Expand Up @@ -577,6 +578,16 @@
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback-version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback-version}</version>
</dependency>
<dependency>
<groupId>org.jmockit</groupId>
<artifactId>jmockit</artifactId>
Expand Down
Loading