mirror of https://github.com/apache/nifi.git
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 <alopresto@apache.org>
This commit is contained in:
parent
878db82375
commit
fa13832a9c
|
@ -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
|
||||
log4j.appender.console.layout.ConversionPattern=%d{yyyy/MM/dd HH:mm:ss} %p [%t] %c: %m%n
|
|
@ -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'])
|
|
@ -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>
|
||||
|
|
|
@ -39,40 +39,28 @@
|
|||
<groupId>org.slf4j</groupId>
|
||||
<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>
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
|
@ -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'])
|
|
@ -45,4 +45,10 @@
|
|||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
Loading…
Reference in New Issue