Skip to content

Consistently use slf4j/log4j bridge#139226

Merged
rjernst merged 10 commits intoelastic:mainfrom
rjernst:logging/slf4j_bridge
Dec 10, 2025
Merged

Consistently use slf4j/log4j bridge#139226
rjernst merged 10 commits intoelastic:mainfrom
rjernst:logging/slf4j_bridge

Conversation

@rjernst
Copy link
Member

@rjernst rjernst commented Dec 9, 2025

Some 3rd party dependencies use SLF4J but Elasticsearch internally uses log4j. Historically there were problems with using the log4j adapter for SLF4J, but those have gone away with the removal of SecurityManager. This commit updates uses of slf4j to consistently use the log4j bridge. Note that long term we should still aim for something more turnkey so that we don't end up with multiple copies of the bridge jar, but this change at least removes warnings about no SLF4J providers being found.

closes #137556

Some 3rd party dependencies use SLF4J but Elasticsearch internally uses
log4j. Historically there were problems with using the log4j adapter for
SLF4J, but those have gone away with the removal of SecurityManager.
This commit updates uses of slf4j to consistently use the log4j bridge.
@rjernst rjernst requested a review from a team as a code owner December 9, 2025 00:14
@rjernst rjernst requested review from DaveCTurner and removed request for a team December 9, 2025 00:14
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

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

LGTM excellent, confirmed to work with e.g.

diff --git a/modules/repository-s3/src/javaRestTest/java/org/elasticsearch/repositories/s3/RepositoryS3BasicCredentialsRestIT.java b/modules/repository-s3/src/javaRestTest/java/org/elasticsearch/repositories/s3/RepositoryS3BasicCredentialsRestIT.java
index dfe3bbbc2613..8757263427d2 100644
--- a/modules/repository-s3/src/javaRestTest/java/org/elasticsearch/repositories/s3/RepositoryS3BasicCredentialsRestIT.java
+++ b/modules/repository-s3/src/javaRestTest/java/org/elasticsearch/repositories/s3/RepositoryS3BasicCredentialsRestIT.java
@@ -50,6 +50,8 @@ public class RepositoryS3BasicCredentialsRestIT extends AbstractRepositoryS3Rest
         .keystore("s3.client." + CLIENT + ".access_key", ACCESS_KEY)
         .keystore("s3.client." + CLIENT + ".secret_key", SECRET_KEY)
         .setting("s3.client." + CLIENT + ".endpoint", s3Fixture::getAddress)
+        .systemProperty("es.insecure_network_trace_enabled", "true")
+        .setting("logger.org.apache.http.headers", "TRACE")
         .build();

     @ClassRule

@DaveCTurner
Copy link
Contributor

NB closes #137556

@DaveCTurner
Copy link
Contributor

I proposed a test to verify the logging in repository-s3 since this is something we describe in the docs (incorrectly, today, but we can fix that).

Note that we restrict the AWS SDK v1 loggers in case they expose sensitive information:

: List.of("org.apache.http", "com.amazonaws.request");

Should we do that for the AWS SDK v2 loggers too? I.e. everything under software.amazon.awssdk.

@rjernst rjernst requested a review from a team as a code owner December 9, 2025 19:26
Comment on lines +53 to +54
.systemProperty("es.insecure_network_trace_enabled", "true")
.setting("logger.org.apache.http.headers", "TRACE")
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need these here, this was just something I mentioned in a review comment as how I verified by hand that it worked. RepositoryS3WireLoggingRestIT is a much more comprehensive test of this.

@rjernst rjernst merged commit 9a473e9 into elastic:main Dec 10, 2025
34 checks passed
@rjernst rjernst deleted the logging/slf4j_bridge branch December 10, 2025 23:03
DaveCTurner added a commit to DaveCTurner/elasticsearch that referenced this pull request Dec 18, 2025
It turns out that the Azure SDK logs copiously at `ERROR` level for
totally benign events such as a `BlobNotFound` response when trying to
delete a blob that has already been deleted. Until elastic#139226 these
messages were screamed into the void and caused no issue, but since that
change landed we now see them in the server logs too.

In due course we'd like to be able to capture these logs at a more
appropriate level, maybe `DEBUG`, but in the meantime this commit
removes the SLF4J bridge from the `repository-azure` module to redirect
them back into the void.
DaveCTurner added a commit to DaveCTurner/elasticsearch that referenced this pull request Dec 18, 2025
It turns out that the Azure SDK logs copiously at `ERROR` level for
totally benign events such as a `BlobNotFound` response when trying to
delete a blob that has already been deleted. Until elastic#139226 these
messages were screamed into the void and caused no issue, but since that
change landed we now see them in the server logs too.

In due course we'd like to be able to capture these logs at a more
appropriate level, maybe `DEBUG`, but in the meantime this commit
removes the SLF4J bridge from the `repository-azure` module to redirect
them back into the void.
DaveCTurner added a commit that referenced this pull request Dec 18, 2025
It turns out that the Azure SDK logs copiously at `ERROR` level for
totally benign events such as a `BlobNotFound` response when trying to
delete a blob that has already been deleted. Until #139226 these
messages were screamed into the void and caused no issue, but since that
change landed we now see them in the server logs too.

In due course we'd like to be able to capture these logs at a more
appropriate level, maybe `DEBUG`, but in the meantime this commit
removes the SLF4J bridge from the `repository-azure` module to redirect
them back into the void.
DaveCTurner added a commit that referenced this pull request Dec 18, 2025
It turns out that the Azure SDK logs copiously at `ERROR` level for
totally benign events such as a `BlobNotFound` response when trying to
delete a blob that has already been deleted. Until #139226 these
messages were screamed into the void and caused no issue, but since that
change landed we now see them in the server logs too.

In due course we'd like to be able to capture these logs at a more
appropriate level, maybe `DEBUG`, but in the meantime this commit
removes the SLF4J bridge from the `repository-azure` module to redirect
them back into the void.
DaveCTurner added a commit to DaveCTurner/elasticsearch that referenced this pull request Dec 18, 2025
It turns out that the Azure SDK logs copiously at `ERROR` level for
totally benign events such as a `BlobNotFound` response when trying to
delete a blob that has already been deleted. Until elastic#139226 these
messages were screamed into the void and caused no issue, but since that
change landed we now see them in the server logs too.

In due course we'd like to be able to capture these logs at a more
appropriate level, maybe `DEBUG`, but in the meantime this commit
removes the SLF4J bridge from the `repository-azure` module to redirect
them back into the void.
elasticsearchmachine pushed a commit that referenced this pull request Dec 18, 2025
It turns out that the Azure SDK logs copiously at `ERROR` level for
totally benign events such as a `BlobNotFound` response when trying to
delete a blob that has already been deleted. Until #139226 these
messages were screamed into the void and caused no issue, but since that
change landed we now see them in the server logs too.

In due course we'd like to be able to capture these logs at a more
appropriate level, maybe `DEBUG`, but in the meantime this commit
removes the SLF4J bridge from the `repository-azure` module to redirect
them back into the void.
@DaveCTurner
Copy link
Contributor

@rjernst I think we're missing backports here, this only seems to be in the 9.3 and main branches at the moment.

@rjernst
Copy link
Member Author

rjernst commented Dec 23, 2025

This is why we need auto-backport by default 🤦

rjernst added a commit to rjernst/elasticsearch that referenced this pull request Dec 23, 2025
Some 3rd party dependencies use SLF4J but Elasticsearch internally uses
log4j. Historically there were problems with using the log4j adapter for
SLF4J, but those have gone away with the removal of SecurityManager.
This commit updates uses of slf4j to consistently use the log4j bridge.

closes elastic#137556

Co-authored-by: David Turner <david.turner@elastic.co>
rjernst added a commit to rjernst/elasticsearch that referenced this pull request Dec 23, 2025
Some 3rd party dependencies use SLF4J but Elasticsearch internally uses
log4j. Historically there were problems with using the log4j adapter for
SLF4J, but those have gone away with the removal of SecurityManager.
This commit updates uses of slf4j to consistently use the log4j bridge.

closes elastic#137556

Co-authored-by: David Turner <david.turner@elastic.co>
rjernst added a commit to rjernst/elasticsearch that referenced this pull request Dec 23, 2025
Some 3rd party dependencies use SLF4J but Elasticsearch internally uses
log4j. Historically there were problems with using the log4j adapter for
SLF4J, but those have gone away with the removal of SecurityManager.
This commit updates uses of slf4j to consistently use the log4j bridge.

closes elastic#137556

Co-authored-by: David Turner <david.turner@elastic.co>
rjernst added a commit to rjernst/elasticsearch that referenced this pull request Dec 23, 2025
Some 3rd party dependencies use SLF4J but Elasticsearch internally uses
log4j. Historically there were problems with using the log4j adapter for
SLF4J, but those have gone away with the removal of SecurityManager.
This commit updates uses of slf4j to consistently use the log4j bridge.

closes elastic#137556

Co-authored-by: David Turner <david.turner@elastic.co>
@rjernst
Copy link
Member Author

rjernst commented Dec 23, 2025

9.2: #139950
9.1: #139951
8.19: #139952

elasticsearchmachine pushed a commit that referenced this pull request Dec 29, 2025
* Consistently use slf4j/log4j bridge (#139226)

Some 3rd party dependencies use SLF4J but Elasticsearch internally uses
log4j. Historically there were problems with using the log4j adapter for
SLF4J, but those have gone away with the removal of SecurityManager.
This commit updates uses of slf4j to consistently use the log4j bridge.

closes #137556

Co-authored-by: David Turner <david.turner@elastic.co>

* remove param from main

* fix dep

* update license

* more licenses

---------

Co-authored-by: David Turner <david.turner@elastic.co>
elasticsearchmachine pushed a commit that referenced this pull request Dec 29, 2025
* Consistently use slf4j/log4j bridge (#139226)

Some 3rd party dependencies use SLF4J but Elasticsearch internally uses
log4j. Historically there were problems with using the log4j adapter for
SLF4J, but those have gone away with the removal of SecurityManager.
This commit updates uses of slf4j to consistently use the log4j bridge.

closes #137556

Co-authored-by: David Turner <david.turner@elastic.co>

* remove param from main

* license update

* more licenses

---------

Co-authored-by: David Turner <david.turner@elastic.co>
elasticsearchmachine pushed a commit that referenced this pull request Dec 29, 2025
* Consistently use slf4j/log4j bridge (#139226)

Some 3rd party dependencies use SLF4J but Elasticsearch internally uses
log4j. Historically there were problems with using the log4j adapter for
SLF4J, but those have gone away with the removal of SecurityManager.
This commit updates uses of slf4j to consistently use the log4j bridge.

closes #137556

Co-authored-by: David Turner <david.turner@elastic.co>

* fix dep

* fix licenses

* more licenses

* fix compile

---------

Co-authored-by: David Turner <david.turner@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Core/Infra/Logging Log management and logging utilities >refactoring serverless-linked Added by automation, don't add manually Team:Core/Infra Meta label for core/infra team v8.19.10 v9.1.10 v9.2.4 v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement SLF4J logging bridge

3 participants

Comments