Merge "Fixed check for TUIs in relation spans"
diff --git a/Changes b/Changes
index a8f1cbf..167c1b1 100644
--- a/Changes
+++ b/Changes
@@ -1,4 +1,4 @@
-0.55.9 2017-12-19
+0.55.9 2018-01-11
         - [bugfix] Serialize token identifier correctly for
           new corpora with text siglen (diewald)
         - [bugfix] Extend bytebuffer for relation payloads (diewald)
@@ -8,6 +8,8 @@
           in snippet generation (diewald)
         - [bugfix] Token cannot contain another token or element (margaretha)
         - [feature] Enabled searching relation query using regex (margaretha)
+        - [bugfix] Fix deserialization of negative regex in sequences (diewald)
+        - [cleanup] Upgraded Log4j to v2 (diewald)
 
 0.55.8 2017-09-05
         - [feature] Retrieve and display pagebreaks (diewald)
diff --git a/Readme.md b/Readme.md
index 3436b05..e9015c2 100644
--- a/Readme.md
+++ b/Readme.md
@@ -82,7 +82,7 @@
 **Authors**: [Nils Diewald](http://nils-diewald.de/),
 	     [Eliza Margaretha](http://www1.ids-mannheim.de/direktion/personal/margaretha.html)
 
-Copyright (c) 2013-2017, [IDS Mannheim](http://ids-mannheim.de/), Germany
+Copyright (c) 2013-2018, [IDS Mannheim](http://ids-mannheim.de/), Germany
 
 Krill is developed as part of the [KorAP](http://korap.ids-mannheim.de/)
 Corpus Analysis Platform at the Institute for German Language
diff --git a/pom.xml b/pom.xml
index 563cd65..d7d361d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -87,19 +87,24 @@
 
 		<!-- log4j dependency -->
 		<dependency>
-			<groupId>log4j</groupId>
-			<artifactId>log4j</artifactId>
-			<version>1.2.17</version>
+			<groupId>org.apache.logging.log4j</groupId>
+			<artifactId>log4j-api</artifactId>
+			<version>2.10.0</version>
 		</dependency>
-		<dependency>
-			<groupId>org.slf4j</groupId>
-			<artifactId>slf4j-log4j12</artifactId>
-			<version>1.7.5</version>
+    <dependency>
+			<groupId>org.apache.logging.log4j</groupId>
+			<artifactId>log4j-core</artifactId>
+			<version>2.10.0</version>
 		</dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <version>2.10.0</version>
+    </dependency>
 		<dependency>
 			<groupId>org.slf4j</groupId>
 			<artifactId>jul-to-slf4j</artifactId>
-			<version>1.7.5</version>
+			<version>1.7.25</version>
 		</dependency>
 
 		<!-- SQLite for database connection tests -->
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();