Updated log4j to log4j2
Change-Id: Ia00e41a9f26b515eb24dc7a6d5e7cd052a1cbeb7
diff --git a/src/main/java/de/ids_mannheim/korap/query/SimpleSpanQuery.java b/src/main/java/de/ids_mannheim/korap/query/SimpleSpanQuery.java
index a01001c..956e4d2 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SimpleSpanQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SimpleSpanQuery.java
@@ -4,7 +4,9 @@
import java.util.List;
import java.util.Set;
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.Query;
@@ -76,7 +78,8 @@
protected String field;
protected boolean collectPayloads;
protected boolean isFieldNull = false;
- private Logger log = Logger.getLogger(SimpleSpanQuery.class);
+ // private Logger log = Logger.getLogger(SimpleSpanQuery.class);
+ private final static Logger log = LoggerFactory.getLogger(SimpleSpanQuery.class);
public SimpleSpanQuery () {}
diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties
deleted file mode 100644
index 1678d9e..0000000
--- a/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,51 +0,0 @@
-log4j.rootLogger = ERROR, stdout
-
-# Queries:
-# log4j.logger.de.ids_mannheim.korap.query.SpanNextQuery = TRACE, stdout
-
-# Spans:
-# log4j.logger.de.ids_mannheim.korap.query.spans.ElementSpans = TRACE, stdout
-# log4j.logger.de.ids_mannheim.korap.query.spans.AttributeSpans = TRACE, stdout
-# log4j.logger.de.ids_mannheim.korap.query.spans.SubSpans = TRACE, stdout
-# log4j.logger.de.ids_mannheim.korap.query.spans.ElementAttributeSpans = TRACE, stdout
-# log4j.logger.de.ids_mannheim.korap.query.spans.KorapTermSpan = TRACE, stdout
-# log4j.logger.de.ids_mannheim.korap.query.spans.WithinSpans = TRACE, stdout
-# log4j.logger.de.ids_mannheim.korap.query.spans.RepetitionSpans = TRACE, stdout
-# log4j.logger.de.ids_mannheim.korap.query.spans.NextSpans = TRACE, stdout
-# log4j.logger.de.ids_mannheim.korap.query.spans.SimpleSpans = TRACE, stdout
-# log4j.logger.de.ids_mannheim.korap.query.spans.ClassSpans = TRACE, stdout
-# log4j.logger.de.ids_mannheim.korap.query.spans.FocusSpans = TRACE, stdout
-# log4j.logger.de.ids_mannheim.korap.query.spans.MatchSpans = TRACE, stdout
-
-org.glassfish.grizzly.http.server.NetworkListener = TRACE, stdout
-
-# Wrappers:
-# log4j.logger.de.ids_mannheim.korap.KrillQuery = TRACE, stdout
-# log4j.logger.de.ids_mannheim.korap.query.wrap.SpanSequenceQueryWrapper = TRACE, stdout
-
-# Collections:
-# log4j.logger.de.ids_mannheim.korap.collection.Filter = TRACE, stdout
-# log4j.logger.de.ids_mannheim.korap.KrillCollection = TRACE, stdout
-
-# Responses:
-# log4j.logger.de.ids_mannheim.korap.server.Node = TRACE, stdout
-# log4j.logger.de.ids_mannheim.korap.response.Match = TRACE, stdout
-
-# Index:
-# log4j.logger.de.ids_mannheim.korap.index.Indexer = INFO, stdout
-# log4j.logger.de.ids_mannheim.korap.KrillIndex = TRACE, stdout
-# log4j.logger.de.ids_mannheim.korap.index.PositionsToOffset = TRACE, stdout
-# log4j.logger.de.ids_mannheim.korap.index.MultiTermTokenStream = TRACE, stdout
-
-# Tests:
-# log4j.logger.de.ids_mannheim.korap.index.TestSegmentIndex = TRACE, stdout
-
-# Server
-# log4j.category.org.glassfish.jersey = TRACE, stdout
-
-log4j.appender.stdout.Target=System.out
-log4j.appender.stdout = org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern = %5p (%F:%L) -> %m%n
-
-# log4j.appender.stdout.Target=System.out
diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..2528735
--- /dev/null
+++ b/src/main/resources/log4j2.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration>
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%5p (%F:%L) -> %m%n"/>
+ </Console>
+ </Appenders>
+ <Loggers>
+ <Root level="error">
+ <AppenderRef ref="Console"/>
+ </Root>
+ <!--
+ <Logger name="org.glassfish.grizzly.http.server.NetworkListener"
+ level="trace">
+ <AppenderRef ref="Console"/>
+ </Logger>
+ <Logger name="de.ids_mannheim.korap.KrillIndex"
+ level="trace">
+ <AppenderRef ref="Console"/>
+ </Logger>
+ -->
+ </Loggers>
+</Configuration>
diff --git a/src/test/java/de/ids_mannheim/korap/server/TestDatabase.java b/src/test/java/de/ids_mannheim/korap/server/TestDatabase.java
index e4848d9..a096c47 100644
--- a/src/test/java/de/ids_mannheim/korap/server/TestDatabase.java
+++ b/src/test/java/de/ids_mannheim/korap/server/TestDatabase.java
@@ -17,15 +17,19 @@
import org.junit.Test;
import org.junit.Ignore;
import static org.junit.Assert.*;
+import org.slf4j.bridge.SLF4JBridgeHandler;
public class TestDatabase {
private Connection conn;
private Statement stat;
-
@Before
public void setUp () throws Exception {
+ SLF4JBridgeHandler.install();
+ System.setProperty("com.mchange.v2.log.MLog", "com.mchange.v2.log.FallbackMLog");
+ System.setProperty("com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL", "WARNING");
+
Class.forName("org.sqlite.JDBC");
conn = DriverManager.getConnection("jdbc:sqlite::memory:");
this.stat = conn.createStatement();