Skip to content

Commit

Permalink
Merge pull request #77 from ngageoint/test-logging-cleanup
Browse files Browse the repository at this point in the history
Ensure Log4j is used for testing
  • Loading branch information
mbrukman committed Feb 5, 2017
2 parents 902ef92 + 25ed615 commit 0a2a117
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 31 deletions.
1 change: 0 additions & 1 deletion janusgraph-cassandra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
</dependency>
<!-- End logging backends. -->
<dependency>
Expand Down
13 changes: 12 additions & 1 deletion janusgraph-es/pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
Expand Down Expand Up @@ -68,6 +67,18 @@
<version>${antlr.version}</version>
</dependency>

<!-- Logging backends.
Enforce a classpath ordering constraint to ensure log4j is used for logging.
See comment in janusgraph-cassandra POM for more information. -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<!-- End logging backends. -->
</dependencies>
<build>
<resources>
Expand Down
21 changes: 12 additions & 9 deletions janusgraph-es/src/test/resources/log4j.properties
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# A1 is set to be a FileAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
#log4j.appender.A1=org.apache.log4j.FileAppender
log4j.appender.A1=org.apache.log4j.FileAppender
log4j.appender.A1.File=target/test.log
log4j.appender.A1.Threshold=TRACE

# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
log4j.appender.A1.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5p %c{2}: %m%n

# A2 is a ConsoleAppender.
log4j.appender.A2=org.apache.log4j.ConsoleAppender
log4j.appender.A2.Threshold=WARN
# A2 uses PatternLayout.
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5p %c{2}: %m%n

# Set root logger level to the designated level and its only appender to A1.
log4j.rootLogger=INFO, A1
# Set both appenders (A1 and A2) on the root logger.
log4j.rootLogger=INFO, A1, A2
#log4j.rootLogger=INFO, A1

log4j.logger.org.apache.cassandra=INFO
log4j.logger.org.apache.hadoop=INFO
log4j.logger.org.apache.zookeeper=INFO
14 changes: 11 additions & 3 deletions janusgraph-hadoop-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,19 @@
<artifactId>sesame-rio-turtle</artifactId>
</dependency>

<!-- LOGGING -->
<!-- Logging backends.
Enforce a classpath ordering constraint to ensure slf4j-log4j12
binding appears on the classpath before logback-classic.
See comments in janusgraph-cassandra/pom.xml for more information. -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<!-- End logging backends. -->

<!-- TESTING -->
<dependency>
Expand Down
8 changes: 8 additions & 0 deletions janusgraph-hbase-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
These declarations could go away if HBase ever fully migrates
to slf4j and removes its hard dependency on log4j.
Note, logback-classic is added explicitly to ensure slf4j-log4j12
binding appears on the classpath before logback-classic. See
comments in janusgraph-cassandra/pom.xml for more information.
-->
<dependency>
<groupId>org.slf4j</groupId>
Expand All @@ -73,6 +77,10 @@
<optional>false</optional>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
22 changes: 13 additions & 9 deletions janusgraph-lucene/src/test/resources/log4j.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
# A1 is set to be a FileAppender.
#log4j.appender.A1=org.apache.log4j.ConsoleAppender
# A1 is a FileAppender.
log4j.appender.A1=org.apache.log4j.FileAppender
log4j.appender.A1.File=target/test.log

log4j.appender.A1.Threshold=TRACE
# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
log4j.appender.A1.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5p %c{2}: %m%n

# A2 is a ConsoleAppender.
log4j.appender.A2=org.apache.log4j.ConsoleAppender
log4j.appender.A2.Threshold=WARN
# A2 uses PatternLayout.
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5p %c{2}: %m%n

# Set root logger level to the designated level and its only appender to A1.
log4j.rootLogger=INFO, A1
# Set both appenders (A1 and A2) on the root logger.
log4j.rootLogger=INFO, A1, A2
#log4j.rootLogger=INFO, A1

log4j.logger.org.apache.cassandra=INFO
log4j.logger.org.apache.hadoop=INFO
log4j.logger.org.apache.zookeeper=INFO
13 changes: 13 additions & 0 deletions janusgraph-solr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@
<artifactId>jts</artifactId>
<version>1.13</version>
</dependency>
<!-- Logging backends.
Enforce a classpath ordering constraint to ensure slf4j-log4j12
binding appears on the classpath before logback-classic.
See comments in janusgraph-cassandra/pom.xml for more information. -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<!-- End logging backends. -->
</dependencies>
<build>
<directory>${basedir}/target</directory>
Expand Down
20 changes: 12 additions & 8 deletions janusgraph-solr/src/test/resources/log4j.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
# A1 is set to be a FileAppender.
#log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1=org.apache.log4j.FileAppender
log4j.appender.A1.File=target/test.log

log4j.appender.A1.Threshold=TRACE
# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
log4j.appender.A1.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5p %c{2}: %m%n

# A2 is a ConsoleAppender.
log4j.appender.A2=org.apache.log4j.ConsoleAppender
log4j.appender.A2.Threshold=WARN
# A2 uses PatternLayout.
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5p %c{2}: %m%n

# Set root logger level to the designated level and its only appender to A1.
log4j.rootLogger=INFO, A1
# Set both appenders (A1 and A2) on the root logger.
log4j.rootLogger=INFO, A1, A2
#log4j.rootLogger=INFO, A1

log4j.logger.org.apache.cassandra=INFO
log4j.logger.org.apache.hadoop=INFO
log4j.logger.org.apache.zookeeper=INFO
24 changes: 24 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,13 @@
</excludes>
<excludedGroups>${test.excluded.groups}</excludedGroups>
<skip>${test.skip.default}</skip>
<!-- Use log4j.properties from module test resources -->
<systemProperties>
<property>
<name>log4j.configuration</name>
<value>file:${project.build.directory}/test-classes/log4j.properties</value>
</property>
</systemProperties>
</configuration>
<executions>
<execution>
Expand All @@ -272,13 +279,25 @@
<exclude>**/*</exclude>
</excludes> -->
<skipTests>${test.skip.tp}</skipTests>
<systemPropertyVariables>
<log4j.configuration>file:${project.build.directory}/test-classes/log4j.properties</log4j.configuration>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.15</version>
<configuration>
<!-- Use log4j.properties from module test resources -->
<systemProperties>
<property>
<name>log4j.configuration</name>
<value>file:${project.build.directory}/test-classes/log4j.properties</value>
</property>
</systemProperties>
</configuration>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
Expand Down Expand Up @@ -598,6 +617,11 @@
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
Expand Down

0 comments on commit 0a2a117

Please sign in to comment.