Skip to content

Commit a98db25

Browse files
authored
fix: Clean up Apache Lucene logging via SLF4j redirect (#7979)
Signed-off-by: Chad Wilson <[email protected]>
1 parent 1e3a83b commit a98db25

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

cli/src/main/resources/logback.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
</encoder>
1111
</appender>
1212

13+
<logger name="org.apache.lucene" level="ERROR" />
1314
<logger name="org.apache.commons.jcs" level="ERROR" />
1415
<logger name="org.apache.hc" level="ERROR" />
1516

core/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,11 @@ Copyright (c) 2012 Jeremy Long. All Rights Reserved.
279279
<groupId>org.apache.lucene</groupId>
280280
<artifactId>lucene-queryparser</artifactId>
281281
</dependency>
282+
<!-- Allow redirection of lucene logs to slf4j -->
283+
<dependency>
284+
<groupId>org.slf4j</groupId>
285+
<artifactId>jul-to-slf4j</artifactId>
286+
</dependency>
282287
<dependency>
283288
<groupId>org.apache.velocity</groupId>
284289
<artifactId>velocity-engine-core</artifactId>

core/src/main/java/org/owasp/dependencycheck/data/cpe/AbstractMemoryIndex.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import org.owasp.dependencycheck.utils.Settings;
5151
import org.slf4j.Logger;
5252
import org.slf4j.LoggerFactory;
53+
import org.slf4j.bridge.SLF4JBridgeHandler;
5354

5455
/**
5556
* <p>
@@ -67,6 +68,12 @@
6768
@ThreadSafe
6869
public abstract class AbstractMemoryIndex implements MemoryIndex {
6970

71+
static {
72+
// Ensure Lucene uses SLF4J for logging
73+
SLF4JBridgeHandler.removeHandlersForRootLogger();
74+
SLF4JBridgeHandler.install();
75+
}
76+
7077
/**
7178
* The logger.
7279
*/

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,7 @@ Copyright (c) 2012 - Jeremy Long
12551255
</dependency>
12561256
<dependency>
12571257
<groupId>org.slf4j</groupId>
1258-
<artifactId>slf4j-simple</artifactId>
1258+
<artifactId>jul-to-slf4j</artifactId>
12591259
<version>${slf4j.version}</version>
12601260
</dependency>
12611261
<dependency>

0 commit comments

Comments
 (0)