You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by mm...@apache.org on 2018/02/23 18:49:39 UTC

[incubator-pulsar] branch master updated: Upgrade to log4j2 dependency and configuration (#680)

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

mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 21d3307  Upgrade to log4j2 dependency and configuration (#680)
21d3307 is described below

commit 21d3307b7ba9575ff174165cb060b8be26619157
Author: Rajan Dhabalia <rd...@apache.org>
AuthorDate: Fri Feb 23 10:49:37 2018 -0800

    Upgrade to log4j2 dependency and configuration (#680)
    
    * Add log4j2 dependency and configuration
    
    * add yamal configuration
    
    * Add more roll-over-file configuration + log4j2-web module
---
 .gitignore                      |  2 +-
 all/pom.xml                     | 28 +++++++++++--
 bin/bookkeeper                  | 10 ++---
 bin/pulsar                      |  8 ++--
 bin/pulsar-admin                |  8 ++--
 bin/pulsar-client               |  8 ++--
 bin/pulsar-daemon               |  4 +-
 bin/pulsar-perf                 |  8 ++--
 conf/log4j.properties           | 73 --------------------------------
 conf/log4j.shell.properties     | 39 -----------------
 conf/log4j2-scripts/filter.js   | 33 +++++++++++++++
 conf/log4j2.yaml                | 93 +++++++++++++++++++++++++++++++++++++++++
 pom.xml                         | 41 +++++++++++++++---
 site/_data/cli/bookkeeper.yaml  |  2 +-
 site/_data/cli/pulsar-perf.yaml |  2 +-
 site/_data/cli/pulsar.yaml      |  2 +-
 16 files changed, 213 insertions(+), 148 deletions(-)

diff --git a/.gitignore b/.gitignore
index 1e194b2..dd1d1bf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,7 +6,7 @@ dependency-reduced-pom.xml
 logs
 /data
 pulsar-broker/tmp.*
-pulsar-broker/src/test/resources/log4j.properties
+pulsar-broker/src/test/resources/log4j2.yaml
 *.log
 
 *.versionsBackup
diff --git a/all/pom.xml b/all/pom.xml
index deddfac..f4a65a5 100644
--- a/all/pom.xml
+++ b/all/pom.xml
@@ -65,13 +65,33 @@
     </dependency>
 
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
+      <artifactId>log4j</artifactId>
+      <groupId>log4j</groupId>
     </dependency>
 
     <dependency>
-      <artifactId>log4j</artifactId>
-      <groupId>log4j</groupId>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+    </dependency>
+  
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-web</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>com.fasterxml.jackson.dataformat</groupId>
+      <artifactId>jackson-dataformat-yaml</artifactId>
+    </dependency>
+  
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
     </dependency>
 
     <dependency>
diff --git a/bin/bookkeeper b/bin/bookkeeper
index 6e4ea22..d2866c4 100755
--- a/bin/bookkeeper
+++ b/bin/bookkeeper
@@ -51,7 +51,7 @@ BINDIR=`dirname "$0"`
 BK_HOME=`cd $BINDIR/..;pwd`
 
 DEFAULT_CONF=$BK_HOME/conf/bookkeper.conf
-DEFAULT_LOG_CONF=$BK_HOME/conf/log4j.properties
+DEFAULT_LOG_CONF=$BK_HOME/conf/log4j2.yaml
 
 source $BK_HOME/conf/bkenv.sh
 
@@ -146,7 +146,7 @@ COMMAND=$1
 shift
 
 if [ $COMMAND == "shell" ]; then
-    DEFAULT_LOG_CONF=$BK_HOME/conf/log4j.shell.properties
+    DEFAULT_LOG_CONF=$BK_HOME/conf/log4j2.yaml
 fi
 
 if [ -z "$BOOKIE_CONF" ]; then
@@ -159,7 +159,7 @@ fi
 
 BOOKIE_CLASSPATH="$BOOKIE_JAR:$BOOKIE_CLASSPATH:$BOOKIE_EXTRA_CLASSPATH"
 BOOKIE_CLASSPATH="`dirname $BOOKIE_LOG_CONF`:$BOOKIE_CLASSPATH"
-OPTS="$OPTS -Dlog4j.configuration=`basename $BOOKIE_LOG_CONF`"
+OPTS="$OPTS -Dlog4j.configurationFile=`basename $BOOKIE_LOG_CONF`"
 
 OPTS="-cp $BOOKIE_CLASSPATH $OPTS"
 
@@ -169,12 +169,12 @@ OPTS="$OPTS $BOOKIE_EXTRA_OPTS"
 OPTS="$OPTS -Djava.net.preferIPv4Stack=true"
 
 # log directory & file
-BOOKIE_ROOT_LOGGER=${BOOKIE_ROOT_LOGGER:-"INFO,CONSOLE"}
+BOOKIE_LOG_APPENDER=${BOOKIE_LOG_APPENDER:-"Console"}
 BOOKIE_LOG_DIR=${BOOKIE_LOG_DIR:-"$BK_HOME/logs"}
 BOOKIE_LOG_FILE=${BOOKIE_LOG_FILE:-"bookkeeper-server.log"}
 
 #Configure log configuration system properties
-OPTS="$OPTS -Dbookkeeper.root.logger=$BOOKIE_ROOT_LOGGER"
+OPTS="$OPTS -Dpulsar.log.appender=$BOOKIE_LOG_APPENDER"
 OPTS="$OPTS -Dbookkeeper.log.dir=$BOOKIE_LOG_DIR"
 OPTS="$OPTS -Dbookkeeper.log.file=$BOOKIE_LOG_FILE"
 
diff --git a/bin/pulsar b/bin/pulsar
index 9309d8a..ed7e988 100755
--- a/bin/pulsar
+++ b/bin/pulsar
@@ -29,7 +29,7 @@ DEFAULT_DISCOVERY_CONF=$PULSAR_HOME/conf/discovery.conf
 DEFAULT_PROXY_CONF=$PULSAR_HOME/conf/proxy.conf
 DEFAULT_STANDALONE_CONF=$PULSAR_HOME/conf/standalone.conf
 DEFAULT_WEBSOCKET_CONF=$PULSAR_HOME/conf/websocket.conf
-DEFAULT_LOG_CONF=$PULSAR_HOME/conf/log4j.properties
+DEFAULT_LOG_CONF=$PULSAR_HOME/conf/log4j2.yaml
 
 if [ -f "$PULSAR_HOME/conf/pulsar_env.sh" ]
 then
@@ -174,7 +174,7 @@ fi
 
 PULSAR_CLASSPATH="$PULSAR_JAR:$PULSAR_CLASSPATH:$PULSAR_EXTRA_CLASSPATH"
 PULSAR_CLASSPATH="`dirname $PULSAR_LOG_CONF`:$PULSAR_CLASSPATH"
-OPTS="$OPTS -Dlog4j.configuration=`basename $PULSAR_LOG_CONF`"
+OPTS="$OPTS -Dlog4j.configurationFile=`basename $PULSAR_LOG_CONF`"
 
 # Ensure we can read bigger content from ZK. (It might be
 # rarely needed when trying to list many z-nodes under a
@@ -186,11 +186,11 @@ OPTS="-cp $PULSAR_CLASSPATH $OPTS"
 OPTS="$OPTS $PULSAR_EXTRA_OPTS"
 
 # log directory & file
-PULSAR_ROOT_LOGGER=${PULSAR_ROOT_LOGGER:-"INFO,CONSOLE"}
+PULSAR_LOG_APPENDER=${PULSAR_LOG_APPENDER:-"Console"}
 PULSAR_LOG_DIR=${PULSAR_LOG_DIR:-"$PULSAR_HOME/logs"}
 
 #Configure log configuration system properties
-OPTS="$OPTS -Dpulsar.root.logger=$PULSAR_ROOT_LOGGER"
+OPTS="$OPTS -Dpulsar.log.appender=$PULSAR_LOG_APPENDER"
 OPTS="$OPTS -Dpulsar.log.dir=$PULSAR_LOG_DIR"
 
 #Change to PULSAR_HOME to support relative paths
diff --git a/bin/pulsar-admin b/bin/pulsar-admin
index 516c538..8de438a 100755
--- a/bin/pulsar-admin
+++ b/bin/pulsar-admin
@@ -22,7 +22,7 @@ BINDIR=$(dirname "$0")
 PULSAR_HOME=`cd $BINDIR/..;pwd`
 
 DEFAULT_CLIENT_CONF=$PULSAR_HOME/conf/client.conf
-DEFAULT_LOG_CONF=$PULSAR_HOME/conf/log4j.properties
+DEFAULT_LOG_CONF=$PULSAR_HOME/conf/log4j2.yaml
 
 if [ -f "$PULSAR_HOME/conf/pulsar_tools_env.sh" ]
 then
@@ -88,7 +88,7 @@ fi
 
 PULSAR_CLASSPATH="$PULSAR_JAR:$PULSAR_CLASSPATH:$PULSAR_EXTRA_CLASSPATH"
 PULSAR_CLASSPATH="`dirname $PULSAR_LOG_CONF`:$PULSAR_CLASSPATH"
-OPTS="$OPTS -Dlog4j.configuration=`basename $PULSAR_LOG_CONF`"
+OPTS="$OPTS -Dlog4j.configurationFile=`basename $PULSAR_LOG_CONF`"
 OPTS="$OPTS -Djava.net.preferIPv4Stack=true"
 
 OPTS="-cp $PULSAR_CLASSPATH $OPTS"
@@ -96,12 +96,12 @@ OPTS="-cp $PULSAR_CLASSPATH $OPTS"
 OPTS="$OPTS $PULSAR_EXTRA_OPTS"
 
 # log directory & file
-PULSAR_ROOT_LOGGER=${PULSAR_ROOT_LOGGER:-"INFO,CONSOLE"}
 PULSAR_LOG_DIR=${PULSAR_LOG_DIR:-"$PULSAR_HOME/logs"}
+PULSAR_LOG_APPENDER=${PULSAR_LOG_APPENDER:-"Console"}
 
 #Configure log configuration system properties
-OPTS="$OPTS -Dpulsar.root.logger=$PULSAR_ROOT_LOGGER"
 OPTS="$OPTS -Dpulsar.log.dir=$PULSAR_LOG_DIR"
+OPTS="$OPTS -Dpulsar.log.appender=$PULSAR_LOG_APPENDER"
 
 #Change to PULSAR_HOME to support relative paths
 cd "$PULSAR_HOME"
diff --git a/bin/pulsar-client b/bin/pulsar-client
index a89878a..650322a 100755
--- a/bin/pulsar-client
+++ b/bin/pulsar-client
@@ -22,7 +22,7 @@ BINDIR=$(dirname "$0")
 PULSAR_HOME=`cd $BINDIR/..;pwd`
 
 DEFAULT_CLIENT_CONF=$PULSAR_HOME/conf/client.conf
-DEFAULT_LOG_CONF=$PULSAR_HOME/conf/log4j.shell.properties
+DEFAULT_LOG_CONF=$PULSAR_HOME/conf/log4j2.yaml
 
 if [ -f "$PULSAR_HOME/conf/pulsar_tools_env.sh" ]
 then
@@ -88,7 +88,7 @@ fi
 
 PULSAR_CLASSPATH="$PULSAR_JAR:$PULSAR_CLASSPATH:$PULSAR_EXTRA_CLASSPATH"
 PULSAR_CLASSPATH="`dirname $PULSAR_LOG_CONF`:$PULSAR_CLASSPATH"
-OPTS="$OPTS -Dlog4j.configuration=`basename $PULSAR_LOG_CONF`"
+OPTS="$OPTS -Dlog4j.configurationFile=`basename $PULSAR_LOG_CONF`"
 OPTS="$OPTS -Djava.net.preferIPv4Stack=true"
 
 OPTS="-cp $PULSAR_CLASSPATH $OPTS"
@@ -96,12 +96,12 @@ OPTS="-cp $PULSAR_CLASSPATH $OPTS"
 OPTS="$OPTS $PULSAR_EXTRA_OPTS"
 
 # log directory & file
-PULSAR_ROOT_LOGGER=${PULSAR_ROOT_LOGGER:-"INFO,CONSOLE"}
 PULSAR_LOG_DIR=${PULSAR_LOG_DIR:-"$PULSAR_HOME/logs"}
+PULSAR_LOG_APPENDER=${PULSAR_LOG_APPENDER:-"Console"}
 
 #Configure log configuration system properties
-OPTS="$OPTS -Dpulsar.root.logger=$PULSAR_ROOT_LOGGER"
 OPTS="$OPTS -Dpulsar.log.dir=$PULSAR_LOG_DIR"
+OPTS="$OPTS -Dpulsar.log.appender=$PULSAR_LOG_APPENDER"
 
 #Change to PULSAR_HOME to support relative paths
 cd "$PULSAR_HOME"
diff --git a/bin/pulsar-daemon b/bin/pulsar-daemon
index 3658659..5853f11 100755
--- a/bin/pulsar-daemon
+++ b/bin/pulsar-daemon
@@ -44,7 +44,7 @@ then
 fi
 
 PULSAR_LOG_DIR=${PULSAR_LOG_DIR:-"$PULSAR_HOME/logs"}
-PULSAR_ROOT_LOGGER=${PULSAR_ROOT_LOGGER:-'INFO,ROLLINGFILE'}
+PULSAR_LOG_APPENDER=${PULSAR_LOG_APPENDER:-"RollingFile"}
 PULSAR_STOP_TIMEOUT=${PULSAR_STOP_TIMEOUT:-30}
 PULSAR_PID_DIR=${PULSAR_PID_DIR:-$PULSAR_HOME/bin}
 
@@ -90,7 +90,7 @@ case $command in
 esac
 
 export PULSAR_LOG_DIR=$PULSAR_LOG_DIR
-export PULSAR_ROOT_LOGGER=$PULSAR_ROOT_LOGGER
+export PULSAR_LOG_APPENDER=$PULSAR_LOG_APPENDER
 export PULSAR_LOG_FILE=pulsar-$command-$HOSTNAME.log
 
 pid=$PULSAR_PID_DIR/pulsar-$command.pid
diff --git a/bin/pulsar-perf b/bin/pulsar-perf
index 287012b..8226b7e 100755
--- a/bin/pulsar-perf
+++ b/bin/pulsar-perf
@@ -22,7 +22,7 @@ BINDIR=$(dirname "$0")
 PULSAR_HOME=`cd $BINDIR/..;pwd`
 
 DEFAULT_CLIENT_CONF=$PULSAR_HOME/conf/client.conf
-DEFAULT_LOG_CONF=$PULSAR_HOME/conf/log4j.properties
+DEFAULT_LOG_CONF=$PULSAR_HOME/conf/log4j2.yaml
 
 if [ -f "$PULSAR_HOME/conf/pulsar_env.sh" ]
 then
@@ -117,18 +117,18 @@ fi
 
 PULSAR_CLASSPATH="$PULSAR_JAR:$PULSAR_CLASSPATH:$PULSAR_EXTRA_CLASSPATH"
 PULSAR_CLASSPATH="`dirname $PULSAR_LOG_CONF`:$PULSAR_CLASSPATH"
-OPTS="$OPTS -Dlog4j.configuration=`basename $PULSAR_LOG_CONF` -Djava.net.preferIPv4Stack=true"
+OPTS="$OPTS -Dlog4j.configurationFile=`basename $PULSAR_LOG_CONF` -Djava.net.preferIPv4Stack=true"
 
 OPTS="-cp $PULSAR_CLASSPATH $OPTS"
 OPTS="$OPTS $PULSAR_EXTRA_OPTS"
 
 # log directory & file
-PULSAR_ROOT_LOGGER=${PULSAR_ROOT_LOGGER:-"INFO,CONSOLE"}
+PULSAR_LOG_APPENDER=${PULSAR_LOG_APPENDER:-"Console"}
 PULSAR_LOG_DIR=${PULSAR_LOG_DIR:-"$PULSAR_HOME/logs"}
 PULSAR_LOG_FILE=${PULSAR_LOG_FILE:-"pulsar-perftest.log"}
 
 #Configure log configuration system properties
-OPTS="$OPTS -Dpulsar.root.logger=$PULSAR_ROOT_LOGGER"
+OPTS="$OPTS -Dpulsar.log.appender=$PULSAR_LOG_APPENDER"
 OPTS="$OPTS -Dpulsar.log.dir=$PULSAR_LOG_DIR"
 OPTS="$OPTS -Dpulsar.log.file=$PULSAR_LOG_FILE"
 
diff --git a/conf/log4j.properties b/conf/log4j.properties
deleted file mode 100644
index 30156f8..0000000
--- a/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
-pulsar.root.logger=WARN,CONSOLE
-pulsar.log.dir=logs
-pulsar.log.file=pulsar.log
-
-log4j.rootLogger=${pulsar.root.logger}
-log4j.logger.org.apache.zookeeper.server.ZooKeeperServer=WARN
-log4j.logger.org.apache.zookeeper.ZooKeeper=WARN
-
-# 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=DEBUG
-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=DEBUG
-log4j.appender.ROLLINGFILE.File=${pulsar.log.dir}/${pulsar.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=pulsar-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 146d153..0000000
--- a/conf/log4j.shell.properties
+++ /dev/null
@@ -1,39 +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 configuration
-
-# DEFAULT: console appender only
-# Define some default values that can be overridden by system properties
-bookkeeper.root.logger=ERROR,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=DEBUG
-log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
-log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p %m%n
-
-log4j.logger.org.apache.zookeeper=ERROR
-log4j.logger.org.apache.bookkeeper=ERROR
-log4j.logger.org.apache.bookkeeper.bookie.BookieShell=INFO
diff --git a/conf/log4j2-scripts/filter.js b/conf/log4j2-scripts/filter.js
new file mode 100644
index 0000000..ad3b491
--- /dev/null
+++ b/conf/log4j2-scripts/filter.js
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+// This is a sample file which can be used by log4j2 to: only log debug-statement which has text: pulsar-topic-name
+var result = false;
+var topicName = "pulsar-topic-name";
+/*
+ * Find more logEvent attributes at : 
+ * https://github.com/apache/logging-log4j2/blob/dbd2d252a1b4139a9bd9eb213c89f28498db6dcf/log4j-core/src/main/java/org/apache/logging/log4j/core/LogEvent.java
+ */
+if (logEvent.getLevel() == "DEBUG"){
+        if(logEvent.getMessage().getFormattedMessage().indexOf(topicName)!=-1) {
+                result = true;  
+        }
+} else {
+        result = true;
+}
+result;
\ No newline at end of file
diff --git a/conf/log4j2.yaml b/conf/log4j2.yaml
new file mode 100644
index 0000000..13b07ad
--- /dev/null
+++ b/conf/log4j2.yaml
@@ -0,0 +1,93 @@
+#
+# 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: INFO
+  monitorInterval: 30
+  name: pulsar
+
+  # Example: logger-filter script
+  Scripts:
+    ScriptFile:
+      name: filter.js
+      language: JavaScript
+      path: ./conf/log4j2-scripts/filter.js
+      charset: UTF-8
+  
+  Appenders:
+  
+    # Console 
+    Console:
+      name: Console
+      target: SYSTEM_OUT
+      PatternLayout:
+        Pattern: "%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"
+        
+   # Rolling file appender configuration
+    RollingFile:
+      name: RollingFile
+      fileName: "${sys:pulsar.log.dir}/${sys:pulsar.log.file}"
+      filePattern: "/${sys:pulsar.log.file}-%d{MM-dd-yyyy}-%i.log.gz"
+      immediateFlush: false
+      PatternLayout:
+        Pattern: "%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"
+      Policies:
+        TimeBasedTriggeringPolicy:
+          interval: 1
+          modulate: true
+        SizeBasedTriggeringPolicy:
+          size: 1 GB
+        # Trigger every day at midnight that also scan 
+        # roll-over strategy that deletes older file
+        CronTriggeringPolicy:
+          schedule: "0 0 0 * * ?"
+      # Delete file older than 30days
+      DefaultRolloverStrategy:
+          Delete:
+            basePath: ${sys:pulsar.log.dir}
+            maxDepth: 2
+            IfFileName:
+              glob: "*/${sys:pulsar.log.file}*log.gz"
+            IfLastModified:
+              age: 30d
+              
+
+  Loggers:
+  
+    # Default root logger configuration
+    Root:
+      level: info
+      additivity: false
+      AppenderRef:
+        ref: "${sys:pulsar.log.appender}"
+    
+    # Logger to inject filter script
+#    Logger:
+#      name: org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl
+#      level: debug
+#      additivity: false
+#      AppenderRef:
+#        ref: "${sys:pulsar.log.appender}"
+#        ScriptFilter:
+#          onMatch: ACCEPT
+#          onMisMatch: DENY
+#          ScriptRef:
+#            ref: filter.js
+        
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index eb97e0b..e708354 100644
--- a/pom.xml
+++ b/pom.xml
@@ -118,6 +118,7 @@ flexible messaging model and an intuitive client API.</description>
     <aspectj.version>1.8.9</aspectj.version>
     <rocksdb.version>5.8.6</rocksdb.version>
     <slf4j.version>1.7.25</slf4j.version>
+    <log4j2.version>2.10.0</log4j2.version>
     <bouncycastle.version>1.55</bouncycastle.version>
     <jackson.version>2.9.3</jackson.version>
     <puppycrawl.checkstyle.version>6.19</puppycrawl.checkstyle.version>
@@ -223,6 +224,12 @@ flexible messaging model and an intuitive client API.</description>
         <groupId>org.apache.bookkeeper.stats</groupId>
         <artifactId>datasketches-metrics-provider</artifactId>
         <version>${bookkeeper.version}</version>
+        <exclusions>
+          <exclusion>
+            <artifactId>slf4j-log4j12</artifactId>
+            <groupId>org.slf4j</groupId>
+          </exclusion>
+        </exclusions>
       </dependency>
 
       <dependency>
@@ -322,21 +329,45 @@ flexible messaging model and an intuitive client API.</description>
       </dependency>
 
       <dependency>
-        <artifactId>slf4j-log4j12</artifactId>
         <groupId>org.slf4j</groupId>
+        <artifactId>slf4j-simple</artifactId>
         <version>${slf4j.version}</version>
       </dependency>
 
       <dependency>
         <groupId>org.slf4j</groupId>
-        <artifactId>slf4j-simple</artifactId>
+        <artifactId>jul-to-slf4j</artifactId>
         <version>${slf4j.version}</version>
       </dependency>
 
       <dependency>
-        <groupId>org.slf4j</groupId>
-        <artifactId>jul-to-slf4j</artifactId>
-        <version>${slf4j.version}</version>
+        <groupId>org.apache.logging.log4j</groupId>
+        <artifactId>log4j-api</artifactId>
+        <version>${log4j2.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.apache.logging.log4j</groupId>
+        <artifactId>log4j-core</artifactId>
+        <version>${log4j2.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.apache.logging.log4j</groupId>
+        <artifactId>log4j-slf4j-impl</artifactId>
+        <version>${log4j2.version}</version>
+      </dependency>
+      
+      <dependency>
+        <groupId>org.apache.logging.log4j</groupId>
+        <artifactId>log4j-web</artifactId>
+        <version>${log4j2.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>com.fasterxml.jackson.dataformat</groupId>
+        <artifactId>jackson-dataformat-yaml</artifactId>
+        <version>2.5.0</version>
       </dependency>
 
       <dependency>
diff --git a/site/_data/cli/bookkeeper.yaml b/site/_data/cli/bookkeeper.yaml
index b14056e..dd44869 100644
--- a/site/_data/cli/bookkeeper.yaml
+++ b/site/_data/cli/bookkeeper.yaml
@@ -57,7 +57,7 @@ commands:
 env_vars:
 - name: BOOKIE_LOG_CONF
   description: Log4j configuration file
-  default: conf/log4j.properties
+  default: conf/log4j2.yaml
 - name: BOOKIE_CONF
   description: BookKeeper configuration file
   default: conf/bk_server.conf
diff --git a/site/_data/cli/pulsar-perf.yaml b/site/_data/cli/pulsar-perf.yaml
index 088a53b..d6772ff 100644
--- a/site/_data/cli/pulsar-perf.yaml
+++ b/site/_data/cli/pulsar-perf.yaml
@@ -131,7 +131,7 @@ commands:
 env_vars:
 - name: PULSAR_LOG_CONF
   description: Log4j configuration file
-  default: conf/log4j.properties
+  default: conf/log4j2.yaml
 - name: PULSAR_CLIENT_CONF
   description: Configuration file for the client
   default: conf/client.conf
diff --git a/site/_data/cli/pulsar.yaml b/site/_data/cli/pulsar.yaml
index f5ae17e..650b18a 100644
--- a/site/_data/cli/pulsar.yaml
+++ b/site/_data/cli/pulsar.yaml
@@ -140,7 +140,7 @@ commands:
 env_vars:
 - name: PULSAR_LOG_CONF
   description: Log4j configuration file
-  default: conf/log4j.properties
+  default: conf/log4j2.yaml
 - name: PULSAR_BROKER_CONF
   description: Configuration file for broker
   default: conf/broker.conf

-- 
To stop receiving notification emails like this one, please contact
mmerli@apache.org.