Skip to content

fix: Clean up Apache Lucene logging via SLF4j redirect#7979

Merged
jeremylong merged 1 commit intodependency-check:mainfrom
chadlwilson:fix-inconsistent-logging
Sep 26, 2025
Merged

fix: Clean up Apache Lucene logging via SLF4j redirect#7979
jeremylong merged 1 commit intodependency-check:mainfrom
chadlwilson:fix-inconsistent-logging

Conversation

@chadlwilson
Copy link
Collaborator

Also suppresses the default logs for users.

Description of Change

Currently there are occasional logs (especially from the Apache Lucene indexing) that are coming through in an consistent format. They are mostly due to warnings about the JVM-in-use (due to use of Azul/Zulu JVM within the docker image rather than Hotspot/Temurin/OpenJDK etc).

  • Added jul-to-slf4j bridge
  • Initialised during Lucene initialization as this seems to be the main JUL dependency, and I couldn't think of a better init location that works across CLI, Maven, Gradle etc.
    • Technically there do seem to be other libraries potentially using java.util.logging, so it might be a better idea to get the logging set up within the Engine or the AbstractAnalyzer if these are the main entry points to core
  • Removed slf4j-simple dependency management definition (unused)
  • Stopped logging lucene errors unless at ERROR level on CLI since these errors are somewhat far from being user-addressable, and inevitable on the Docker image. This change is up for debate.

Before (via CLI on temurin-21 in docker image)

[INFO] Finished Version Filter Analyzer (0 seconds)
Sep 25, 2025 8:40:55 AM org.apache.lucene.util.HotspotVMOptions <clinit>
WARNING: Lucene cannot optimize algorithms or calculate object sizes for JVMs that are not based on Hotspot or a compatible implementation.
WARNING: A restricted method in java.lang.foreign.Linker has been called
WARNING: java.lang.foreign.Linker::downcallHandle has been called by the unnamed module
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for this module

Sep 25, 2025 8:40:56 AM org.apache.lucene.store.MemorySegmentIndexInputProvider <init>
INFO: Using MemorySegmentIndexInput and native madvise support with Java 21 or later; to disable start with -Dorg.apache.lucene.store.MMapDirectory.enableMemorySegments=false
Sep 25, 2025 8:40:56 AM org.apache.lucene.internal.vectorization.VectorizationProvider lookup
WARNING: Java runtime is not using Hotspot VM; Java vector incubator API can't be enabled.

You'll get varying different warnings depending on OpenJDK vs Zulu and different versions.

After - without Lucene log suppression (via CLI)

[INFO] Finished Version Filter Analyzer (0 seconds)
[WARN] Lucene cannot optimize algorithms or calculate object sizes for JVMs that are not based on Hotspot or a compatible implementation.
WARNING: A restricted method in java.lang.foreign.Linker has been called
WARNING: java.lang.foreign.Linker::downcallHandle has been called by the unnamed module
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for this module

[INFO] Using MemorySegmentIndexInput and native madvise support with Java 21 or later; to disable start with -Dorg.apache.lucene.store.MMapDirectory.enableMemorySegments=false
[WARN] Java runtime is not using Hotspot VM; Java vector incubator API can't be enabled.

After - with warning suppression (via CLI)

[INFO] Finished Version Filter Analyzer (0 seconds)
WARNING: A restricted method in java.lang.foreign.Linker has been called
WARNING: java.lang.foreign.Linker::downcallHandle has been called by the unnamed module
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for this module

Related issues

Partially addresses #7759 but does not address the JVM warnings.

Have test cases been added to cover the new functionality?

no

Also suppresses the default logs for users.

Signed-off-by: Chad Wilson <29788154+chadlwilson@users.noreply.github.com>
@boring-cyborg boring-cyborg bot added cli changes to the cli core changes to core labels Sep 26, 2025
Copy link
Collaborator

@jeremylong jeremylong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jeremylong jeremylong added this to the 12.1.7 milestone Sep 26, 2025
@jeremylong jeremylong merged commit a98db25 into dependency-check:main Sep 26, 2025
7 checks passed
@chadlwilson chadlwilson deleted the fix-inconsistent-logging branch September 26, 2025 17:27
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cli changes to the cli core changes to core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments