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 7 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
82 changes: 0 additions & 82 deletions conf/log4j.properties

This file was deleted.

112 changes: 112 additions & 0 deletions conf/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<!--
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>

<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.Log4jAuditLogger" additivity="false" level="${audit.logger}">
<appender-ref ref="RFAAUDIT" />
</logger-->

<root level="INFO">
<appender-ref ref="CONSOLE" />
</root>
</configuration>
22 changes: 9 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -459,11 +459,11 @@

<!-- dependency versions -->
<slf4j.version>1.7.30</slf4j.version>
<logback-version>1.2.7</logback-version>
anmolnar marked this conversation as resolved.
Show resolved Hide resolved
<audience-annotations.version>0.12.0</audience-annotations.version>
<jmockit.version>1.48</jmockit.version>
<junit.version>5.6.2</junit.version>
<junit-platform.version>1.6.2</junit-platform.version>
<log4j.version>1.2.17</log4j.version>
<mockito.version>3.6.28</mockito.version>
<hamcrest.version>2.2</hamcrest.version>
<commons-cli.version>1.4</commons-cli.version>
Expand Down Expand Up @@ -562,20 +562,14 @@
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback-version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback-version}</version>
</dependency>
<dependency>
<groupId>org.jmockit</groupId>
Expand Down Expand Up @@ -608,11 +602,13 @@
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
Copy link
Member

Choose a reason for hiding this comment

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

It's not a good idea to put the <scope> in the <dependencyManagement> section of the POM, because that will propagate, and require the <scope>compile</scope> to be explicitly added (normally, it's not needed, because it's the default scope). It's better to just manage the version in the <dependencyManagement> section, and defer adding a scope until the dependency is actually used.

It is unlikely that these dependencies are going to be used in a scope other than test, but the only reason to put the scope here is to omit it later when it is used. However, omitting it later will make it appear as though the scope is used is the compile scope, so it doesn't really have any benefit to adding it here.

</dependency>
<dependency>
<groupId>io.netty</groupId>
Expand Down

This file was deleted.

Loading