From 89228a52dc3d1cfb734c4173c7b0ab68457eccbf Mon Sep 17 00:00:00 2001 From: bgamard Date: Fri, 14 Feb 2020 21:33:34 +0100 Subject: [PATCH] Closes #378: silence useless log from Jersey --- .../docs/core/util/indexing/LuceneIndexingHandler.java | 3 +-- docs-web-common/pom.xml | 5 +++++ .../com/sismics/util/filter/RequestContextFilter.java | 3 +++ docs-web/src/dev/resources/log4j.properties | 2 ++ docs-web/src/prod/resources/log4j.properties | 3 ++- pom.xml | 9 ++++++++- 6 files changed, 21 insertions(+), 4 deletions(-) diff --git a/docs-core/src/main/java/com/sismics/docs/core/util/indexing/LuceneIndexingHandler.java b/docs-core/src/main/java/com/sismics/docs/core/util/indexing/LuceneIndexingHandler.java index 5a190c58..a1ca6bae 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/util/indexing/LuceneIndexingHandler.java +++ b/docs-core/src/main/java/com/sismics/docs/core/util/indexing/LuceneIndexingHandler.java @@ -46,7 +46,6 @@ import org.slf4j.LoggerFactory; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.sql.Timestamp; import java.util.*; @@ -390,7 +389,7 @@ public class LuceneIndexingHandler implements IndexingHandler { LuceneDictionary dictionary = new LuceneDictionary(directoryReader, "title"); suggester.build(dictionary); int lastIndex = search.lastIndexOf(' '); - String suggestQuery = search.substring(lastIndex < 0 ? 0 : lastIndex); + String suggestQuery = search.substring(Math.max(lastIndex, 0)); List lookupResultList = suggester.lookup(suggestQuery, false, 10); for (Lookup.LookupResult lookupResult : lookupResultList) { suggestionList.add(lookupResult.key.toString()); diff --git a/docs-web-common/pom.xml b/docs-web-common/pom.xml index 20d53ded..be6c07b2 100644 --- a/docs-web-common/pom.xml +++ b/docs-web-common/pom.xml @@ -68,6 +68,11 @@ joda-time joda-time + + + org.slf4j + jul-to-slf4j + diff --git a/docs-web-common/src/main/java/com/sismics/util/filter/RequestContextFilter.java b/docs-web-common/src/main/java/com/sismics/util/filter/RequestContextFilter.java index 224998c4..8fecd0fb 100644 --- a/docs-web-common/src/main/java/com/sismics/util/filter/RequestContextFilter.java +++ b/docs-web-common/src/main/java/com/sismics/util/filter/RequestContextFilter.java @@ -11,6 +11,7 @@ import org.apache.log4j.PatternLayout; import org.apache.log4j.RollingFileAppender; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.slf4j.bridge.SLF4JBridgeHandler; import javax.persistence.EntityManager; import javax.persistence.EntityTransaction; @@ -57,6 +58,8 @@ public class RequestContextFilter implements Filter { fileAppender.setMaxBackupIndex(5); fileAppender.activateOptions(); org.apache.log4j.Logger.getRootLogger().addAppender(fileAppender); + SLF4JBridgeHandler.removeHandlersForRootLogger(); + SLF4JBridgeHandler.install(); // Initialize the application context TransactionUtil.handle(AppContext::getInstance); diff --git a/docs-web/src/dev/resources/log4j.properties b/docs-web/src/dev/resources/log4j.properties index 0b05e8e9..91f327c9 100644 --- a/docs-web/src/dev/resources/log4j.properties +++ b/docs-web/src/dev/resources/log4j.properties @@ -6,3 +6,5 @@ log4j.appender.MEMORY=com.sismics.util.log4j.MemoryAppender log4j.appender.MEMORY.size=1000 log4j.logger.com.sismics=DEBUG +log4j.logger.org.apache.pdfbox=ERROR +log4j.logger.org.glassfish.jersey.servlet.WebComponent=ERROR \ No newline at end of file diff --git a/docs-web/src/prod/resources/log4j.properties b/docs-web/src/prod/resources/log4j.properties index 130264d3..75203ec9 100644 --- a/docs-web/src/prod/resources/log4j.properties +++ b/docs-web/src/prod/resources/log4j.properties @@ -6,4 +6,5 @@ log4j.appender.MEMORY=com.sismics.util.log4j.MemoryAppender log4j.appender.MEMORY.size=1000 log4j.logger.com.sismics=INFO -log4j.logger.org.apache.pdfbox=ERROR \ No newline at end of file +log4j.logger.org.apache.pdfbox=ERROR +log4j.logger.org.glassfish.jersey.servlet.WebComponent=ERROR \ No newline at end of file diff --git a/pom.xml b/pom.xml index b3b8adb0..51c8b900 100644 --- a/pom.xml +++ b/pom.xml @@ -26,6 +26,7 @@ 1.2.16 1.6.4 1.6.6 + 1.6.6 4.12 1.4.197 2.27 @@ -240,7 +241,13 @@ jcl-over-slf4j ${org.slf4j.jcl-over-slf4j.version} - + + + org.slf4j + jul-to-slf4j + ${org.slf4j.jul-to-slf4j.version} + + junit junit