Closes #378: silence useless log from Jersey

This commit is contained in:
bgamard 2020-02-14 21:33:34 +01:00
parent 90a49efa4a
commit 89228a52dc
6 changed files with 21 additions and 4 deletions

View File

@ -46,7 +46,6 @@ import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.*; import java.util.*;
@ -390,7 +389,7 @@ public class LuceneIndexingHandler implements IndexingHandler {
LuceneDictionary dictionary = new LuceneDictionary(directoryReader, "title"); LuceneDictionary dictionary = new LuceneDictionary(directoryReader, "title");
suggester.build(dictionary); suggester.build(dictionary);
int lastIndex = search.lastIndexOf(' '); int lastIndex = search.lastIndexOf(' ');
String suggestQuery = search.substring(lastIndex < 0 ? 0 : lastIndex); String suggestQuery = search.substring(Math.max(lastIndex, 0));
List<Lookup.LookupResult> lookupResultList = suggester.lookup(suggestQuery, false, 10); List<Lookup.LookupResult> lookupResultList = suggester.lookup(suggestQuery, false, 10);
for (Lookup.LookupResult lookupResult : lookupResultList) { for (Lookup.LookupResult lookupResult : lookupResultList) {
suggestionList.add(lookupResult.key.toString()); suggestionList.add(lookupResult.key.toString());

View File

@ -69,6 +69,11 @@
<artifactId>joda-time</artifactId> <artifactId>joda-time</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
</dependency>
<!-- Test dependencies --> <!-- Test dependencies -->
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>

View File

@ -11,6 +11,7 @@ import org.apache.log4j.PatternLayout;
import org.apache.log4j.RollingFileAppender; import org.apache.log4j.RollingFileAppender;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.slf4j.bridge.SLF4JBridgeHandler;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction; import javax.persistence.EntityTransaction;
@ -57,6 +58,8 @@ public class RequestContextFilter implements Filter {
fileAppender.setMaxBackupIndex(5); fileAppender.setMaxBackupIndex(5);
fileAppender.activateOptions(); fileAppender.activateOptions();
org.apache.log4j.Logger.getRootLogger().addAppender(fileAppender); org.apache.log4j.Logger.getRootLogger().addAppender(fileAppender);
SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();
// Initialize the application context // Initialize the application context
TransactionUtil.handle(AppContext::getInstance); TransactionUtil.handle(AppContext::getInstance);

View File

@ -6,3 +6,5 @@ log4j.appender.MEMORY=com.sismics.util.log4j.MemoryAppender
log4j.appender.MEMORY.size=1000 log4j.appender.MEMORY.size=1000
log4j.logger.com.sismics=DEBUG log4j.logger.com.sismics=DEBUG
log4j.logger.org.apache.pdfbox=ERROR
log4j.logger.org.glassfish.jersey.servlet.WebComponent=ERROR

View File

@ -7,3 +7,4 @@ log4j.appender.MEMORY.size=1000
log4j.logger.com.sismics=INFO log4j.logger.com.sismics=INFO
log4j.logger.org.apache.pdfbox=ERROR log4j.logger.org.apache.pdfbox=ERROR
log4j.logger.org.glassfish.jersey.servlet.WebComponent=ERROR

View File

@ -26,6 +26,7 @@
<log4j.log4j.version>1.2.16</log4j.log4j.version> <log4j.log4j.version>1.2.16</log4j.log4j.version>
<org.slf4j.version>1.6.4</org.slf4j.version> <org.slf4j.version>1.6.4</org.slf4j.version>
<org.slf4j.jcl-over-slf4j.version>1.6.6</org.slf4j.jcl-over-slf4j.version> <org.slf4j.jcl-over-slf4j.version>1.6.6</org.slf4j.jcl-over-slf4j.version>
<org.slf4j.jul-to-slf4j.version>1.6.6</org.slf4j.jul-to-slf4j.version>
<junit.junit.version>4.12</junit.junit.version> <junit.junit.version>4.12</junit.junit.version>
<com.h2database.h2.version>1.4.197</com.h2database.h2.version> <com.h2database.h2.version>1.4.197</com.h2database.h2.version>
<org.glassfish.jersey.version>2.27</org.glassfish.jersey.version> <org.glassfish.jersey.version>2.27</org.glassfish.jersey.version>
@ -241,6 +242,12 @@
<version>${org.slf4j.jcl-over-slf4j.version}</version> <version>${org.slf4j.jcl-over-slf4j.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>${org.slf4j.jul-to-slf4j.version}</version>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>