You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by al...@apache.org on 2016/11/16 23:52:14 UTC

nifi git commit: NIFI-3049 Fixes logging issues due to logback and log4j being on the classpath Removed logback usage from classpath Added slf4j-log4j12 dependency in nifi-toolkit pom Added logback-classic exclusion for nifi-properties-loader used by nif

Repository: nifi
Updated Branches:
  refs/heads/master 878db8237 -> fa13832a9


NIFI-3049 Fixes logging issues due to logback and log4j being on the classpath
Removed logback usage from classpath
Added slf4j-log4j12 dependency in nifi-toolkit pom
Added logback-classic exclusion for nifi-properties-loader used by nifi-toolkit-encrypt-config
Updated log4j.properties logging pattern and logger config in nifi-toolkit-assembly and nifi-toolkit-zookeeper-migrator, filtering zookeeper messages below WARN
Removed logback.groovy since log4j is the single logging implementation
Updated ZooKeeperMigratorMain command line output to match standards established by other tools in nifi-toolkit

This closes #1237.

Signed-off-by: Andy LoPresto <al...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/fa13832a
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/fa13832a
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/fa13832a

Branch: refs/heads/master
Commit: fa13832a9c07b20e968efc5d8baf7e7e09e1a7b1
Parents: 878db82
Author: Jeff Storck <jt...@gmail.com>
Authored: Wed Nov 16 17:41:12 2016 -0500
Committer: Andy LoPresto <al...@apache.org>
Committed: Wed Nov 16 15:33:11 2016 -0800

----------------------------------------------------------------------
 .../main/resources/classpath/log4j.properties   |  4 +-
 .../src/main/resources/classpath/logback.groovy | 39 -------------------
 .../nifi-toolkit-encrypt-config/pom.xml         |  6 +++
 .../nifi-toolkit-zookeeper-migrator/pom.xml     | 40 +++++++-------------
 .../zkmigrator/ZooKeeperMigratorMain.java       | 13 +++++--
 .../src/test/resources/log4j.properties         | 24 ++++++++++++
 .../src/test/resources/logback.groovy           | 39 -------------------
 nifi-toolkit/pom.xml                            |  6 +++
 8 files changed, 63 insertions(+), 108 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/fa13832a/nifi-toolkit/nifi-toolkit-assembly/src/main/resources/classpath/log4j.properties
----------------------------------------------------------------------
diff --git a/nifi-toolkit/nifi-toolkit-assembly/src/main/resources/classpath/log4j.properties b/nifi-toolkit/nifi-toolkit-assembly/src/main/resources/classpath/log4j.properties
index fc2aaf1..6072b3e 100644
--- a/nifi-toolkit/nifi-toolkit-assembly/src/main/resources/classpath/log4j.properties
+++ b/nifi-toolkit/nifi-toolkit-assembly/src/main/resources/classpath/log4j.properties
@@ -17,6 +17,8 @@
 
 log4j.rootLogger=INFO,console
 
+log4j.logger.org.apache.zookeeper=WARN,console
+
 log4j.appender.console=org.apache.log4j.ConsoleAppender
 log4j.appender.console.layout=org.apache.log4j.PatternLayout
-log4j.appender.console.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{2}: %m%n
\ No newline at end of file
+log4j.appender.console.layout.ConversionPattern=%d{yyyy/MM/dd HH:mm:ss} %p [%t] %c: %m%n
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/nifi/blob/fa13832a/nifi-toolkit/nifi-toolkit-assembly/src/main/resources/classpath/logback.groovy
----------------------------------------------------------------------
diff --git a/nifi-toolkit/nifi-toolkit-assembly/src/main/resources/classpath/logback.groovy b/nifi-toolkit/nifi-toolkit-assembly/src/main/resources/classpath/logback.groovy
deleted file mode 100644
index ac77f24..0000000
--- a/nifi-toolkit/nifi-toolkit-assembly/src/main/resources/classpath/logback.groovy
+++ /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.
- */
-import ch.qos.logback.classic.encoder.PatternLayoutEncoder
-import ch.qos.logback.core.ConsoleAppender
-import ch.qos.logback.core.status.NopStatusListener
-
-statusListener(NopStatusListener)
-
-appender('stdout', ConsoleAppender) {
-    target = 'System.out'
-    encoder(PatternLayoutEncoder) {
-        pattern = "%date %level [%thread] %logger{40} %msg%n"
-    }
-}
-
-appender('stderr', ConsoleAppender) {
-    target = 'System.err'
-    encoder(PatternLayoutEncoder) {
-        pattern = "%date %level [%thread] %logger{40} %msg%n"
-    }
-}
-
-logger("org.apache.nifi.toolkit.zkmigrator", INFO)
-logger("org.apache.zookeeper", WARN)
-root(WARN, ['stderr'])

http://git-wip-us.apache.org/repos/asf/nifi/blob/fa13832a/nifi-toolkit/nifi-toolkit-encrypt-config/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-toolkit/nifi-toolkit-encrypt-config/pom.xml b/nifi-toolkit/nifi-toolkit-encrypt-config/pom.xml
index 977c8b1..3b094c7 100644
--- a/nifi-toolkit/nifi-toolkit-encrypt-config/pom.xml
+++ b/nifi-toolkit/nifi-toolkit-encrypt-config/pom.xml
@@ -31,6 +31,12 @@
         <dependency>
             <groupId>org.apache.nifi</groupId>
             <artifactId>nifi-properties-loader</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>ch.qos.logback</groupId>
+                    <artifactId>logback-classic</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.apache.nifi</groupId>

http://git-wip-us.apache.org/repos/asf/nifi/blob/fa13832a/nifi-toolkit/nifi-toolkit-zookeeper-migrator/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-toolkit/nifi-toolkit-zookeeper-migrator/pom.xml b/nifi-toolkit/nifi-toolkit-zookeeper-migrator/pom.xml
index 536fbce..0273dd7 100644
--- a/nifi-toolkit/nifi-toolkit-zookeeper-migrator/pom.xml
+++ b/nifi-toolkit/nifi-toolkit-zookeeper-migrator/pom.xml
@@ -40,40 +40,28 @@
             <artifactId>slf4j-api</artifactId>
         </dependency>
         <dependency>
-            <groupId>ch.qos.logback</groupId>
-            <artifactId>logback-classic</artifactId>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
             <groupId>org.apache.zookeeper</groupId>
             <artifactId>zookeeper</artifactId>
-            <!--<exclusions>-->
-                <!-- these exclusions can be used once the ZK dependency is upgraded to 3.5.2 or 3.6.0
-                which do not have the hard dependency on log4j -->
-                <!--<exclusion>-->
-                    <!--<groupId>log4j</groupId>-->
-                    <!--<artifactId>log4j</artifactId>-->
-                <!--</exclusion>-->
-                <!--<exclusion>-->
-                    <!--<groupId>org.slf4j</groupId>-->
-                    <!--<artifactId>slf4j-api</artifactId>-->
-                <!--</exclusion>-->
-                <!--<exclusion>-->
-                    <!--<groupId>org.slf4j</groupId>-->
-                    <!--<artifactId>slf4j-log4j12</artifactId>-->
-                <!--</exclusion>-->
-            <!--</exclusions>-->
+            <exclusions>
+                <exclusion>
+                    <groupId>log4j</groupId>
+                    <artifactId>log4j</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-api</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-log4j12</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>com.google.code.gson</groupId>
             <artifactId>gson</artifactId>
         </dependency>
         <dependency>
-            <!-- explicitly declaring for logback's runtime processing of logback.groovy -->
-            <groupId>org.codehaus.groovy</groupId>
-            <artifactId>groovy-all</artifactId>
-        </dependency>
-        <dependency>
             <groupId>org.spockframework</groupId>
             <artifactId>spock-core</artifactId>
             <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/nifi/blob/fa13832a/nifi-toolkit/nifi-toolkit-zookeeper-migrator/src/main/java/org/apache/nifi/toolkit/zkmigrator/ZooKeeperMigratorMain.java
----------------------------------------------------------------------
diff --git a/nifi-toolkit/nifi-toolkit-zookeeper-migrator/src/main/java/org/apache/nifi/toolkit/zkmigrator/ZooKeeperMigratorMain.java b/nifi-toolkit/nifi-toolkit-zookeeper-migrator/src/main/java/org/apache/nifi/toolkit/zkmigrator/ZooKeeperMigratorMain.java
index bf037a0..c8488a1 100644
--- a/nifi-toolkit/nifi-toolkit-zookeeper-migrator/src/main/java/org/apache/nifi/toolkit/zkmigrator/ZooKeeperMigratorMain.java
+++ b/nifi-toolkit/nifi-toolkit-zookeeper-migrator/src/main/java/org/apache/nifi/toolkit/zkmigrator/ZooKeeperMigratorMain.java
@@ -37,13 +37,19 @@ public class ZooKeeperMigratorMain {
 
     enum Mode {READ, WRITE}
 
+    private static final String JAVA_HOME = "JAVA_HOME";
+    private static final String NIFI_TOOLKIT_HOME = "NIFI_TOOLKIT_HOME";
+    private static final String HEADER = System.lineSeparator() + "A tool for importing and exporting data from ZooKeeper." + System.lineSeparator() + System.lineSeparator();
+    private static final String FOOTER = new StringBuilder(System.lineSeparator()).append("Java home: ")
+            .append(System.getenv(JAVA_HOME)).append(System.lineSeparator()).append("NiFi Toolkit home: ").append(System.getenv(NIFI_TOOLKIT_HOME)).toString();
+
     private static final Option OPTION_ZK_MIGRATOR_HELP = Option.builder("h")
             .longOpt("help")
             .desc("display help/usage info")
             .build();
     private static final Option OPTION_ZK_ENDPOINT = Option.builder("z")
             .longOpt("zookeeper")
-            .desc("ZooKeeper connect string with path (ex. host:port/path)")
+            .desc("ZooKeeper endpoint string (ex. host:port/path)")
             .hasArg()
             .argName("zookeeper-endpoint")
             .required()
@@ -95,11 +101,12 @@ public class ZooKeeperMigratorMain {
     private static void printUsage(String errorMessage, Options options) {
         Preconditions.checkNotNull(options, "command line options were not specified");
         if (errorMessage != null) {
-            System.out.println(String.format("%s\n", errorMessage));
+            System.out.println(errorMessage + System.lineSeparator());
         }
         HelpFormatter helpFormatter = new HelpFormatter();
         helpFormatter.setWidth(160);
-        helpFormatter.printHelp(ZooKeeperMigratorMain.class.getCanonicalName(), options, true);
+        helpFormatter.setDescPadding(0);
+        helpFormatter.printHelp(ZooKeeperMigratorMain.class.getCanonicalName(), HEADER, options, FOOTER, true);
     }
 
     public static void main(String[] args) {

http://git-wip-us.apache.org/repos/asf/nifi/blob/fa13832a/nifi-toolkit/nifi-toolkit-zookeeper-migrator/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/nifi-toolkit/nifi-toolkit-zookeeper-migrator/src/test/resources/log4j.properties b/nifi-toolkit/nifi-toolkit-zookeeper-migrator/src/test/resources/log4j.properties
new file mode 100644
index 0000000..6072b3e
--- /dev/null
+++ b/nifi-toolkit/nifi-toolkit-zookeeper-migrator/src/test/resources/log4j.properties
@@ -0,0 +1,24 @@
+#
+# 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.
+#
+
+log4j.rootLogger=INFO,console
+
+log4j.logger.org.apache.zookeeper=WARN,console
+
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%d{yyyy/MM/dd HH:mm:ss} %p [%t] %c: %m%n
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/nifi/blob/fa13832a/nifi-toolkit/nifi-toolkit-zookeeper-migrator/src/test/resources/logback.groovy
----------------------------------------------------------------------
diff --git a/nifi-toolkit/nifi-toolkit-zookeeper-migrator/src/test/resources/logback.groovy b/nifi-toolkit/nifi-toolkit-zookeeper-migrator/src/test/resources/logback.groovy
deleted file mode 100644
index ac77f24..0000000
--- a/nifi-toolkit/nifi-toolkit-zookeeper-migrator/src/test/resources/logback.groovy
+++ /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.
- */
-import ch.qos.logback.classic.encoder.PatternLayoutEncoder
-import ch.qos.logback.core.ConsoleAppender
-import ch.qos.logback.core.status.NopStatusListener
-
-statusListener(NopStatusListener)
-
-appender('stdout', ConsoleAppender) {
-    target = 'System.out'
-    encoder(PatternLayoutEncoder) {
-        pattern = "%date %level [%thread] %logger{40} %msg%n"
-    }
-}
-
-appender('stderr', ConsoleAppender) {
-    target = 'System.err'
-    encoder(PatternLayoutEncoder) {
-        pattern = "%date %level [%thread] %logger{40} %msg%n"
-    }
-}
-
-logger("org.apache.nifi.toolkit.zkmigrator", INFO)
-logger("org.apache.zookeeper", WARN)
-root(WARN, ['stderr'])

http://git-wip-us.apache.org/repos/asf/nifi/blob/fa13832a/nifi-toolkit/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-toolkit/pom.xml b/nifi-toolkit/pom.xml
index a898fe7..fe8fafa 100644
--- a/nifi-toolkit/pom.xml
+++ b/nifi-toolkit/pom.xml
@@ -45,4 +45,10 @@
             </dependency>
         </dependencies>
     </dependencyManagement>
+    <dependencies>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+        </dependency>
+    </dependencies>
 </project>