summaryrefslogtreecommitdiff
path: root/conf
diff options
context:
space:
mode:
authorAndor Molnar <andor@apache.org>2022-01-27 10:06:29 +0100
committerEnrico Olivelli <eolivelli@apache.org>2022-01-27 10:06:29 +0100
commit85551f9be5b054fa4aee0636597b12bda2ecb2e8 (patch)
tree37e12f5c57c477619db7dc92178b55c8cc0139a8 /conf
parent957f8fc0afbeca638f13f6fb739e49a921da2b9d (diff)
downloadzookeeper-85551f9be5b054fa4aee0636597b12bda2ecb2e8.tar.gz
ZOOKEEPER-4427: Migrate to Logback
This is the first commit of Logback migration task. 1. Replaced log4j dependencies with logback alternatives, 2. Replaced log4j.properties files with logback.xml 3. Refactored unit tests to use logback for log capturing. This patch doesn't cover the zookeeper-contrib projects, only the main codebase. Author: Andor Molnar <andor@apache.org> Reviewers: Enrico Olivelli <eolivelli@apache.org>, Chris Nauroth <cnauroth@apache.org>, Mate Szalay-Beko <symat@apache.org> Closes #1793 from anmolnar/ZOOKEEPER-4427
Diffstat (limited to 'conf')
-rw-r--r--conf/log4j.properties82
-rw-r--r--conf/logback.xml114
2 files changed, 114 insertions, 82 deletions
diff --git a/conf/log4j.properties b/conf/log4j.properties
deleted file mode 100644
index 9e12a38d3..000000000
--- a/conf/log4j.properties
+++ /dev/null
@@ -1,82 +0,0 @@
-# Copyright 2012 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
-zookeeper.root.logger=INFO, CONSOLE
-
-zookeeper.console.threshold=INFO
-
-zookeeper.log.dir=.
-zookeeper.log.file=zookeeper.log
-zookeeper.log.threshold=INFO
-zookeeper.log.maxfilesize=256MB
-zookeeper.log.maxbackupindex=20
-
-zookeeper.tracelog.dir=${zookeeper.log.dir}
-zookeeper.tracelog.file=zookeeper_trace.log
-
-log4j.rootLogger=${zookeeper.root.logger}
-
-#
-# console
-# Add "console" to rootlogger above if you want to use this
-#
-log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.Threshold=${zookeeper.console.threshold}
-log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
-log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n
-
-#
-# Add ROLLINGFILE to rootLogger to get log file output
-#
-log4j.appender.ROLLINGFILE=org.apache.log4j.RollingFileAppender
-log4j.appender.ROLLINGFILE.Threshold=${zookeeper.log.threshold}
-log4j.appender.ROLLINGFILE.File=${zookeeper.log.dir}/${zookeeper.log.file}
-log4j.appender.ROLLINGFILE.MaxFileSize=${zookeeper.log.maxfilesize}
-log4j.appender.ROLLINGFILE.MaxBackupIndex=${zookeeper.log.maxbackupindex}
-log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout
-log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n
-
-#
-# Add TRACEFILE to rootLogger to get log file output
-# Log TRACE level and above messages to a log file
-#
-log4j.appender.TRACEFILE=org.apache.log4j.FileAppender
-log4j.appender.TRACEFILE.Threshold=TRACE
-log4j.appender.TRACEFILE.File=${zookeeper.tracelog.dir}/${zookeeper.tracelog.file}
-
-log4j.appender.TRACEFILE.layout=org.apache.log4j.PatternLayout
-### Notice we are including log4j's NDC here (%x)
-log4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L][%x] - %m%n
-#
-# zk audit logging
-#
-zookeeper.auditlog.file=zookeeper_audit.log
-zookeeper.auditlog.threshold=INFO
-audit.logger=INFO, RFAAUDIT
-log4j.logger.org.apache.zookeeper.audit.Log4jAuditLogger=${audit.logger}
-log4j.additivity.org.apache.zookeeper.audit.Log4jAuditLogger=false
-log4j.appender.RFAAUDIT=org.apache.log4j.RollingFileAppender
-log4j.appender.RFAAUDIT.File=${zookeeper.log.dir}/${zookeeper.auditlog.file}
-log4j.appender.RFAAUDIT.layout=org.apache.log4j.PatternLayout
-log4j.appender.RFAAUDIT.layout.ConversionPattern=%d{ISO8601} %p %c{2}: %m%n
-log4j.appender.RFAAUDIT.Threshold=${zookeeper.auditlog.threshold}
-
-# Max log file size of 10MB
-log4j.appender.RFAAUDIT.MaxFileSize=10MB
-log4j.appender.RFAAUDIT.MaxBackupIndex=10
diff --git a/conf/logback.xml b/conf/logback.xml
new file mode 100644
index 000000000..84a538969
--- /dev/null
+++ b/conf/logback.xml
@@ -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>