Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
07de6cb
Upgrade to log4j 2.25.1
Rassyan Jul 30, 2025
fa58bb5
Update docs/changelog/132166.yaml
Rassyan Jul 30, 2025
d497868
Upgrade to log4j 2.25.1
Rassyan Jul 30, 2025
aad42ba
Merge branch 'main' into log4j_2_25_1
mosche Sep 1, 2025
8555df5
Upgrade to log4j 2.25.1
Rassyan Jul 30, 2025
4f8bd14
Update docs/changelog/132166.yaml
Rassyan Jul 30, 2025
ddcbe34
Upgrade to log4j 2.25.1
Rassyan Jul 30, 2025
96b5069
run ./gradlew precommit --write-verification-metadata sha256
Rassyan Sep 15, 2025
62b20ef
Merge remote-tracking branch 'origin/log4j_2_25_1' into log4j_2_25_1
Rassyan Sep 15, 2025
9a8e5e8
Merge branch 'main' into log4j_2_25_1
Rassyan Sep 15, 2025
55eb69c
fix thirdPartyAudit
mosche Sep 17, 2025
c332dca
Merge branch 'main' into log4j_2_25_1
elasticmachine Sep 17, 2025
efb6f6c
Ignore Log4j package scanning deprecation warning in tests
Rassyan Sep 18, 2025
959249c
Silence more log4j2 warnings
mosche Sep 18, 2025
eb7c7d7
Merge branch 'main' into log4j_2_25_1
mosche Sep 18, 2025
2ffa884
consistently use warn as level for logger.deprecation.level
mosche Sep 18, 2025
c2c5963
Merge branch 'main' into log4j_2_25_1
mosche Sep 19, 2025
714291b
Ensure SearchPhaseExecutionException returns a stable and consistent …
mosche Sep 19, 2025
ec261d2
Merge branch 'main' into log4j_2_25_1
mosche Sep 19, 2025
ca7f51a
Merge branch 'main' into log4j_2_25_1
mosche Sep 22, 2025
801541a
Merge branch 'main' into log4j_2_25_1
mosche Sep 24, 2025
96db8d4
Expand mismatch description in case of unexpected Log4j2 status logs
mosche Sep 25, 2025
e35602b
Merge branch 'main' into log4j_2_25_1
mosche Sep 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build-tools-internal/version.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jackson = 2.15.0
snakeyaml = 2.0
icu4j = 77.1
supercsv = 2.4.0
log4j = 2.19.0
log4j = 2.25.1
slf4j = 2.0.6
ecsLogging = 1.2.0
jna = 5.12.1
Expand Down
6 changes: 6 additions & 0 deletions docs/changelog/132166.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 132166
summary: Upgrade to log4j 2.25.1
area: Infra/Logging
type: upgrade
issues:
- 132035
25 changes: 25 additions & 0 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,11 @@
<sha256 value="3ef6c9f822b601aa151e10e123b49e5604243a4a99bcc47e4e1f9eea9781dc63" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.github.spotbugs" name="spotbugs-annotations" version="4.8.6">
<artifact name="spotbugs-annotations-4.8.6.jar">
<sha256 value="4548b74a815ed44f5480ca4f06204a8b00809dc7e5f6a825a9edf18f40377b65" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.github.spullara.mustache.java" name="compiler" version="0.9.10">
<artifact name="compiler-0.9.10.jar">
<sha256 value="2b5a9217811cb99846a473fa8e0d233eb33629347b7f44941f6c0fbd4cdf1038" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -687,6 +692,11 @@
<sha256 value="baf7d6ea97ce606c53e11b6854ba5f2ce7ef5c24dddf0afa18d1260bd25b002c" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.google.errorprone" name="error_prone_annotations" version="2.38.0">
<artifact name="error_prone_annotations-2.38.0.jar">
<sha256 value="6661d5335090a5fc61dd869d2095bc6c1e2156e3aa47a6e4ababdf64c99a7889" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.google.errorprone" name="error_prone_annotations" version="2.36.0">
<artifact name="error_prone_annotations-2.36.0.jar">
<sha256 value="77440e270b0bc9a249903c5a076c36a722c4886ca4f42675f2903a1c53ed61a5" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -3110,6 +3120,11 @@
<sha256 value="60480a6c81978a9871099e002997df84a05fc11789fb248e3e803a0dcb19e0cd" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.apache.logging.log4j" name="log4j-1.2-api" version="2.25.1">
<artifact name="log4j-1.2-api-2.25.1.jar">
<sha256 value="6b3babf23e3dd6f3d9db992beb7cf12ea96ba2a19164d61d1ab3e5ce7ba42c2b" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.apache.logging.log4j" name="log4j-api" version="2.17.1">
<artifact name="log4j-api-2.17.1.jar">
<sha256 value="b0d8a4c8ab4fb8b1888d0095822703b0e6d4793c419550203da9e69196161de4" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -3175,11 +3190,21 @@
<sha256 value="47f768ffd66107a66f0c2a19445ab1e42ce6719a7f30f9aa9ef96157c83949fd" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.apache.logging.log4j" name="log4j-jcl" version="2.25.1">
<artifact name="log4j-jcl-2.25.1.jar">
<sha256 value="f9dd2fdf1b924f2f037ea496f886c79940b24aab2e0f0eb1b008680d00265be6" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.apache.logging.log4j" name="log4j-slf4j-impl" version="2.19.0">
<artifact name="log4j-slf4j-impl-2.19.0.jar">
<sha256 value="015d5c229f3cd5c0ebf175c1da08d596d94043362ae9d92637d88848c90537c8" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.apache.logging.log4j" name="log4j-slf4j-impl" version="2.25.1">
<artifact name="log4j-slf4j-impl-2.25.1.jar">
<sha256 value="af6528455568ece7828b9eb621d1baad6341cd2608b12e47055bbba10f718248" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.apache.lucene" name="lucene-analysis-common" version="10.3.0">
<artifact name="lucene-analysis-common-10.3.0.jar">
<sha256 value="124bddea3fa0683d3e174552fba5fcf0f24a2f57f1ccf6957010d010d246db8b" origin="Generated by Gradle"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ appender.header_warning.type = HeaderWarningAppender
appender.header_warning.name = header_warning

logger.deprecation.name = deprecation
logger.deprecation.level = deprecation
logger.deprecation.level = warn
logger.deprecation.appenderRef.deprecation_file.ref = deprecation_file
logger.deprecation.appenderRef.header_warning.ref = header_warning
logger.deprecation.additivity = false
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ appender.header_warning.type = HeaderWarningAppender
appender.header_warning.name = header_warning

logger.deprecation.name = deprecation
logger.deprecation.level = deprecation
logger.deprecation.level = warn
logger.deprecation.appenderRef.deprecation_file.ref = deprecation_file
logger.deprecation.appenderRef.header_warning.ref = header_warning
logger.deprecation.additivity = false
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ appender.header_warning.type = HeaderWarningAppender
appender.header_warning.name = header_warning

logger.deprecation.name = deprecation
logger.deprecation.level = deprecation
logger.deprecation.level = warn
logger.deprecation.appenderRef.deprecation_file.ref = deprecation_file
logger.deprecation.appenderRef.header_warning.ref = header_warning
logger.deprecation.additivity = false
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ appender.header_warning.type = HeaderWarningAppender
appender.header_warning.name = header_warning

logger.deprecation.name = org.elasticsearch.deprecation.common.settings
logger.deprecation.level = deprecation
logger.deprecation.level = warn
logger.deprecation.appenderRef.deprecation_console.ref = console
logger.deprecation.appenderRef.deprecation_file.ref = deprecation_file
logger.deprecation.appenderRef.header_warning.ref = header_warning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ appender.header_warning.type = HeaderWarningAppender
appender.header_warning.name = header_warning
#################################################
logger.deprecation.name = org.elasticsearch.deprecation
logger.deprecation.level = deprecation
logger.deprecation.level = warn
logger.deprecation.appenderRef.deprecation_rolling.ref = deprecation_rolling
logger.deprecation.appenderRef.deprecation_rolling_old.ref = deprecation_rolling_old
logger.deprecation.appenderRef.header_warning.ref = header_warning
Expand Down
16 changes: 14 additions & 2 deletions server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ tasks.named("thirdPartyAudit").configure {
'com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider',
'com.fasterxml.jackson.databind.ser.std.StdScalarSerializer',
'com.fasterxml.jackson.databind.ser.std.StdSerializer',
'com.fasterxml.jackson.databind.util.ClassUtil',
'com.fasterxml.jackson.dataformat.xml.JacksonXmlModule',
'com.fasterxml.jackson.dataformat.xml.XmlMapper',
'com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter',
'org.fusesource.jansi.Ansi',
'org.fusesource.jansi.AnsiRenderer$Code',
'com.lmax.disruptor.EventFactory',
'com.lmax.disruptor.EventHandler',
'com.lmax.disruptor.EventTranslator',
'com.lmax.disruptor.EventTranslatorTwoArg',
'com.lmax.disruptor.EventTranslatorVararg',
Expand Down Expand Up @@ -246,6 +246,7 @@ tasks.named("thirdPartyAudit").configure {
'org.apache.commons.csv.QuoteMode',
'org.apache.kafka.clients.producer.Producer',
'org.apache.kafka.clients.producer.RecordMetadata',
'org.apache.kafka.common.serialization.ByteArraySerializer',
'org.codehaus.stax2.XMLStreamWriter2',
'org.jctools.queues.MpscArrayQueue',
'org.osgi.framework.Bundle',
Expand All @@ -257,13 +258,24 @@ tasks.named("thirdPartyAudit").configure {
'org.osgi.framework.ServiceReference',
'org.osgi.framework.ServiceRegistration',
'org.osgi.framework.SynchronousBundleListener',
'org.osgi.framework.wiring.BundleRevision',
'org.osgi.framework.wiring.BundleWire',
'org.osgi.framework.wiring.BundleWiring',
'org.zeromq.SocketType',
'org.zeromq.ZContext',
'org.zeromq.ZMonitor',
'org.zeromq.ZMonitor$Event',
'org.zeromq.ZMonitor$ZEvent',
'org.zeromq.ZMQ$Context',
'org.zeromq.ZMQ$Socket',
'org.zeromq.ZMQ',
)
ignoreMissingClasses 'javax.xml.bind.DatatypeConverter'

ignoreViolations(
'org.apache.logging.log4j.core.util.internal.UnsafeUtil',
'org.apache.logging.log4j.core.util.internal.UnsafeUtil$1',
)
}

tasks.named("dependencyLicenses").configure {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,26 @@
public class SearchPhaseExecutionException extends ElasticsearchException {
private final String phaseName;
private final ShardSearchFailure[] shardFailures;
private final ElasticsearchException guessedCause; // log4j requires a stable cause!

public SearchPhaseExecutionException(String phaseName, String msg, ShardSearchFailure[] shardFailures) {
this(phaseName, msg, null, shardFailures);
}

@SuppressWarnings("this-escape")
public SearchPhaseExecutionException(String phaseName, String msg, Throwable cause, ShardSearchFailure[] shardFailures) {
super(msg, deduplicateCause(cause, shardFailures));
this.phaseName = phaseName;
this.shardFailures = shardFailures;
this.guessedCause = cause == null || super.getCause() == null ? guessFirstRootCause(shardFailures) : null;
}

@SuppressWarnings("this-escape")
public SearchPhaseExecutionException(StreamInput in) throws IOException {
super(in);
phaseName = in.readOptionalString();
shardFailures = in.readArray(ShardSearchFailure::readShardSearchFailure, ShardSearchFailure[]::new);
guessedCause = super.getCause() == null ? guessFirstRootCause(shardFailures) : null;
}

@Override
Expand Down Expand Up @@ -96,14 +101,9 @@ public ShardSearchFailure[] shardFailures() {

@Override
public Throwable getCause() {
// note: log4j requires this to return a stable, consistent cause when called multiple times
Throwable cause = super.getCause();
if (cause == null) {
// fall back to guessed root cause
for (ElasticsearchException rootCause : guessRootCauses()) {
return rootCause;
}
}
return cause;
return cause != null ? cause : guessedCause;
}

@Override
Expand Down Expand Up @@ -144,6 +144,16 @@ public ElasticsearchException[] guessRootCauses() {
return rootCauses.toArray(new ElasticsearchException[0]);
}

private static ElasticsearchException guessFirstRootCause(ShardSearchFailure[] shardFailures) {
for (ShardOperationFailedException failure : shardFailures) {
ElasticsearchException[] rootCauses = ElasticsearchException.guessRootCauses(failure.getCause());
if (rootCauses.length > 0) {
return rootCauses[0];
}
}
return null;
}

@Override
public String toString() {
return "Failed to execute phase ["
Expand Down
53 changes: 36 additions & 17 deletions test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,11 @@
import org.elasticsearch.xcontent.XContentParser.Token;
import org.elasticsearch.xcontent.XContentParserConfiguration;
import org.elasticsearch.xcontent.XContentType;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.hamcrest.TypeSafeMatcher;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
Expand Down Expand Up @@ -223,10 +225,9 @@
import static java.util.Collections.emptyMap;
import static org.elasticsearch.common.util.CollectionUtils.arrayAsArrayList;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.emptyCollectionOf;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.everyItem;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.startsWith;

Expand Down Expand Up @@ -823,11 +824,20 @@ public void log(StatusData data) {

// Tolerate the absence or otherwise denial of these specific lookup classes.
// At some future time, we should require the JDNI warning.
private static final List<String> LOG_4J_MSG_PREFIXES = List.of(
"JNDI lookup class is not available because this JRE does not support JNDI. "
+ "JNDI string lookups will not be available, continuing configuration.",
"JMX runtime input lookup class is not available because this JRE does not support JMX. "
+ "JMX lookups will not be available, continuing configuration. "
private static final Matcher<String> LOG_4J_MSG_PREFIXES = anyOf(
startsWith(
"JNDI lookup class is not available because this JRE does not support JNDI. "
+ "JNDI string lookups will not be available, continuing configuration."
),
startsWith(
"JMX runtime input lookup class is not available because this JRE does not support JMX. "
+ "JMX lookups will not be available, continuing configuration. "
),
// TODO migrate to annotation processor https://github.com/elastic/elasticsearch/issues/135022
startsWith("The use of package scanning to locate Log4j plugins is deprecated."),
startsWith("Some custom `Core` Log4j plugins are not properly registered"),
startsWith("Some custom `Converter` Log4j plugins are not properly registered"),
startsWith("No Root logger was configured, creating default ERROR-level Root logger with Console appender")
);

// separate method so that this can be checked again after suite scoped cluster is shut down
Expand All @@ -836,16 +846,25 @@ protected static void checkStaticState() throws Exception {
assertThat(StatusLogger.getLogger().getLevel(), equalTo(Level.WARN));
synchronized (statusData) {
try {
// ensure that there are no status logger messages which would indicate a problem with our Log4j usage; we map the
// StatusData instances to Strings as otherwise their toString output is useless
assertThat(
statusData.stream().map(status -> status.getMessage().getFormattedMessage()).collect(Collectors.toList()),
anyOf(
emptyCollectionOf(String.class),
contains(startsWith(LOG_4J_MSG_PREFIXES.get(0)), startsWith(LOG_4J_MSG_PREFIXES.get(1))),
contains(startsWith(LOG_4J_MSG_PREFIXES.get(1)))
)
);
// ensure that there are no status logger messages which would indicate a problem with our Log4j usage;
assertThat(statusData, everyItem(new TypeSafeMatcher<StatusData>() {
@Override
protected boolean matchesSafely(StatusData item) {
return LOG_4J_MSG_PREFIXES.matches(item.getFormattedStatus());
}

@Override
public void describeTo(Description description) {
LOG_4J_MSG_PREFIXES.describeTo(description);
}

@Override
protected void describeMismatchSafely(StatusData item, Description mismatchDescription) {
// make sure we see log4j exceptions in case of issues
mismatchDescription.appendText("was ").appendValue(item.getFormattedStatus());
}
}));

} finally {
// we clear the list so that status data from other tests do not interfere with tests within the same JVM
statusData.clear();
Expand Down
2 changes: 1 addition & 1 deletion test/framework/src/main/resources/log4j2-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ appender.header_warning.type = HeaderWarningAppender
appender.header_warning.name = header_warning

logger.deprecation.name = org.elasticsearch.deprecation
logger.deprecation.level = deprecation
logger.deprecation.level = warn
logger.deprecation.appenderRef.header_warning.ref = header_warning
4 changes: 1 addition & 3 deletions x-pack/plugin/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ esplugin {
tasks.named("dependencyLicenses").configure {
mapping from: /http.*/, to: 'httpclient' // pulled in by rest client
mapping from: /commons-.*/, to: 'commons' // pulled in by rest client
mapping from: /slf4j-.*/, to: 'slf4j'
mapping from: /slf4j-.*/, to: 'slf4j'
}

configurations {
Expand Down Expand Up @@ -157,8 +157,6 @@ tasks.named("thirdPartyAudit").configure {
'javax.jms.Message',
// HttpClient5 can use Conscrypt (TLS using BoringSSL), but we don't want that
'org.conscrypt.Conscrypt',
// SLF4j via HttpClient5
'org.slf4j.ext.EventData'
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.message.EntryMessage;
import org.apache.logging.log4j.message.FlowMessageFactory;
import org.apache.logging.log4j.message.Message;
import org.apache.logging.log4j.message.MessageFactory;
import org.apache.logging.log4j.util.MessageSupplier;
Expand Down Expand Up @@ -930,6 +931,11 @@ public <MF extends MessageFactory> MF getMessageFactory() {
return null;
}

@Override
public FlowMessageFactory getFlowMessageFactory() {
return null;
}

@Override
public String getName() {
return null;
Expand Down
7 changes: 0 additions & 7 deletions x-pack/plugin/ent-search/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,6 @@ tasks.named("dependencyLicenses") {
mapping from: /jackson.*/, to: 'jackson'
}

tasks.named("thirdPartyAudit") {
ignoreMissingClasses(
// [missing classes] SLF4j includes an optional class that depends on an extension class (!)
'org.slf4j.ext.EventData'
)
}

tasks.named("yamlRestTest") {
usesDefaultDistribution("uses the xpack/usage api")
}
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugin/identity-provider/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,6 @@ tasks.named("thirdPartyAudit").configure {
'org.bouncycastle.operator.jcajce.JcaContentSignerBuilder',
'org.bouncycastle.util.Arrays',
'org.bouncycastle.util.io.Streams',
// SLF4j
'org.slf4j.ext.EventData'
)

ignoreViolations(
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugin/security/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,6 @@ tasks.named("thirdPartyAudit").configure {
'javax.activation.DataSource',
'javax.activation.FileDataSource',
'javax.activation.FileTypeMap',
// SLF4j
'org.slf4j.ext.EventData'
)
}

Expand Down