From 378ec136373d71995c88a1d389ca94e5128a04fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Volkan=20Yaz=C4=B1c=C4=B1?=
Date: Thu, 27 Aug 2026 11:57:55 +0200
Subject: [PATCH 1/6] Switch the default minimum allowed plugin processor
message severity from NOTE to ERROR
---
.../processor/GraalVmProcessorTest.java | 23 +++++++++++++------
.../PluginProcessorPublicSetterTest.java | 13 ++++-------
.../plugins/processor/GraalVmProcessor.java | 4 ++--
.../plugins/processor/PluginProcessor.java | 6 ++---
4 files changed, 26 insertions(+), 20 deletions(-)
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/GraalVmProcessorTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/GraalVmProcessorTest.java
index f46150f4a35..650b6f3f707 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/GraalVmProcessorTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/GraalVmProcessorTest.java
@@ -216,9 +216,14 @@ void reachabilityMetadataPath(@Nullable String groupId, @Nullable String artifac
}
@Test
- void whenNoGroupIdAndArtifactId_thenWarningIsPrinted(@TempDir(cleanup = CleanupMode.NEVER) Path outputDir)
+ void whenNoGroupIdAndArtifactId_thenWarningIsEmittedWhenConfigured(@TempDir(cleanup = CleanupMode.NEVER) Path outputDir)
throws Exception {
- List diagnostics = generateDescriptor(sourceDir, null, null, outputDir);
+ List diagnostics = generateDescriptor(
+ sourceDir,
+ null,
+ null,
+ outputDir,
+ "-A" + PluginProcessor.MIN_ALLOWED_MESSAGE_KIND_OPTION + "=WARNING");
assertThat(diagnostics).hasSize(1);
// The warning message should contain the information about the missing groupId and artifactId arguments
assertThat(diagnostics.get(0))
@@ -241,9 +246,14 @@ void whenNoGroupIdAndArtifactId_thenWarningIsPrinted(@TempDir(cleanup = CleanupM
}
@Test
- void noteEmittedByDefaultWithLog4jPrefix(@TempDir Path outputDir) throws Exception {
+ void noteEmittedWhenConfiguredWithLog4jPrefix(@TempDir Path outputDir) throws Exception {
List> diagnostics =
- generateDiagnostics(sourceDir, GROUP_ID, ARTIFACT_ID, outputDir);
+ generateDiagnostics(
+ sourceDir,
+ GROUP_ID,
+ ARTIFACT_ID,
+ outputDir,
+ "-A" + PluginProcessor.MIN_ALLOWED_MESSAGE_KIND_OPTION + "=NOTE");
assertThat(diagnostics)
.anyMatch(diagnostic -> diagnostic.getKind() == Diagnostic.Kind.NOTE
@@ -253,13 +263,12 @@ void noteEmittedByDefaultWithLog4jPrefix(@TempDir Path outputDir) throws Excepti
}
@Test
- void notesSuppressedWithoutAffectingMetadataGeneration(@TempDir Path outputDir) throws Exception {
+ void notesSuppressedByDefaultWithoutAffectingMetadataGeneration(@TempDir Path outputDir) throws Exception {
List> diagnostics = generateDiagnostics(
sourceDir,
GROUP_ID,
ARTIFACT_ID,
- outputDir,
- "-A" + PluginProcessor.MIN_ALLOWED_MESSAGE_KIND_OPTION + "=warning");
+ outputDir);
assertThat(diagnostics)
.noneMatch(diagnostic -> diagnostic.getKind() == Diagnostic.Kind.NOTE
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessorPublicSetterTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessorPublicSetterTest.java
index 3772cced4dc..0d44f12e9cd 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessorPublicSetterTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessorPublicSetterTest.java
@@ -113,7 +113,8 @@ void ignoreWarningWhenSuppressWarningsIsPresent() {
}
@Test
- void noteEmittedByDefault() {
+ void noteEmittedWhenConfigured() {
+ setupWithOptions("-A" + PluginProcessor.MIN_ALLOWED_MESSAGE_KIND_OPTION + "=NOTE");
final List> noteDiagnostics = diagnosticCollector.getDiagnostics().stream()
.filter(d -> d.getKind() == Diagnostic.Kind.NOTE)
.collect(Collectors.toList());
@@ -141,7 +142,7 @@ void errorsStillEmittedWhenMinKindIsError() {
@ParameterizedTest
@ValueSource(strings = {"NOTE", "note"})
- void explicitNoteKindBehavesLikeDefault(final String kindValue) {
+ void explicitNoteKindEmitsNotes(final String kindValue) {
setupWithOptions("-A" + PluginProcessor.MIN_ALLOWED_MESSAGE_KIND_OPTION + "=" + kindValue);
assertThat(errorDiagnostics).anyMatch(d -> d.getMessage(Locale.ROOT)
@@ -154,17 +155,13 @@ void explicitNoteKindBehavesLikeDefault(final String kindValue) {
}
@Test
- void invalidKindValueEmitsWarning() {
+ void invalidKindValueDoesNotEmitWarningByDefault() {
setupWithOptions("-A" + PluginProcessor.MIN_ALLOWED_MESSAGE_KIND_OPTION + "=INVALID");
final List> warningDiagnostics =
diagnosticCollector.getDiagnostics().stream()
.filter(d -> d.getKind() == Diagnostic.Kind.WARNING)
.collect(Collectors.toList());
- assertThat(warningDiagnostics)
- .anyMatch(d -> d.getMessage(Locale.ROOT)
- .startsWith(
- "[Log4j] org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor:")
- && d.getMessage(Locale.ROOT).contains("unrecognized value `INVALID`"));
+ assertThat(warningDiagnostics).isEmpty();
}
}
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/GraalVmProcessor.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/GraalVmProcessor.java
index 05528f96a92..b35344054b8 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/GraalVmProcessor.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/GraalVmProcessor.java
@@ -84,7 +84,7 @@ public class GraalVmProcessor extends AbstractProcessor {
private final Map reachableTypes = new HashMap<>();
private final List processedElements = new ArrayList<>();
private Annotations annotationUtil;
- private Diagnostic.Kind minAllowedMessageKind = Diagnostic.Kind.NOTE;
+ private Diagnostic.Kind minAllowedMessageKind = Diagnostic.Kind.ERROR;
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
@@ -102,7 +102,7 @@ public synchronized void init(ProcessingEnvironment processingEnv) {
GraalVmProcessor.class.getName(),
kindValue,
PluginProcessor.MIN_ALLOWED_MESSAGE_KIND_OPTION,
- Diagnostic.Kind.NOTE,
+ Diagnostic.Kind.ERROR,
Arrays.toString(Diagnostic.Kind.values())));
}
}
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor.java
index 51b7e091090..4896d30dbba 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor.java
@@ -83,7 +83,7 @@ public class PluginProcessor extends AbstractProcessor {
*
*
* Accepted values (case-insensitive): {@code NOTE}, {@code WARNING}, {@code MANDATORY_WARNING},
- * {@code ERROR}, {@code OTHER}. Defaults to {@code NOTE}.
+ * {@code ERROR}, {@code OTHER}. Defaults to {@code ERROR}.
*
*/
static final String MIN_ALLOWED_MESSAGE_KIND_OPTION = "log4j.plugin.processor.minAllowedMessageKind";
@@ -97,7 +97,7 @@ public class PluginProcessor extends AbstractProcessor {
private final List processedElements = new ArrayList<>();
private final PluginCache pluginCache = new PluginCache();
- private Diagnostic.Kind minAllowedMessageKind = Diagnostic.Kind.NOTE;
+ private Diagnostic.Kind minAllowedMessageKind = Diagnostic.Kind.ERROR;
@Override
public void init(final ProcessingEnvironment processingEnv) {
@@ -114,7 +114,7 @@ public void init(final ProcessingEnvironment processingEnv) {
PluginProcessor.class.getName(),
kindValue,
MIN_ALLOWED_MESSAGE_KIND_OPTION,
- Diagnostic.Kind.NOTE,
+ Diagnostic.Kind.ERROR,
Arrays.toString(Diagnostic.Kind.values())));
}
}
From ec2853fc7e0f0e9808adee245668424f6e3b42c5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Volkan=20Yaz=C4=B1c=C4=B1?=
Date: Thu, 27 Aug 2026 11:59:54 +0200
Subject: [PATCH 2/6] Add changelog
---
.../4225_plugin_processor_allowed_messages.xml | 13 +++++++++++++
.../.2.x.x/4225_plugin_processor_messages.xml | 2 +-
2 files changed, 14 insertions(+), 1 deletion(-)
create mode 100644 src/changelog/.2.x.x/4225_plugin_processor_allowed_messages.xml
diff --git a/src/changelog/.2.x.x/4225_plugin_processor_allowed_messages.xml b/src/changelog/.2.x.x/4225_plugin_processor_allowed_messages.xml
new file mode 100644
index 00000000000..0427c07389e
--- /dev/null
+++ b/src/changelog/.2.x.x/4225_plugin_processor_allowed_messages.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+ Switch the default minimum allowed plugin processor message severity from NOTE to ERROR
+
+
diff --git a/src/changelog/.2.x.x/4225_plugin_processor_messages.xml b/src/changelog/.2.x.x/4225_plugin_processor_messages.xml
index f52ac661a7e..9a8eb33686f 100644
--- a/src/changelog/.2.x.x/4225_plugin_processor_messages.xml
+++ b/src/changelog/.2.x.x/4225_plugin_processor_messages.xml
@@ -4,7 +4,7 @@
xsi:schemaLocation="
https://logging.apache.org/xml/ns
https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
- type="changed">
+ type="fixed">
From 2296cc60f97515a69031cd90c6f6986248cc1cb1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Volkan=20Yaz=C4=B1c=C4=B1?=
Date: Tue, 15 Sep 2026 16:21:02 +0200
Subject: [PATCH 3/6] Store the default in a constant
---
.../core/config/plugins/processor/GraalVmProcessor.java | 5 +++--
.../log4j/core/config/plugins/processor/PluginProcessor.java | 5 +++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/GraalVmProcessor.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/GraalVmProcessor.java
index b35344054b8..4e27ec94bea 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/GraalVmProcessor.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/GraalVmProcessor.java
@@ -84,7 +84,8 @@ public class GraalVmProcessor extends AbstractProcessor {
private final Map reachableTypes = new HashMap<>();
private final List processedElements = new ArrayList<>();
private Annotations annotationUtil;
- private Diagnostic.Kind minAllowedMessageKind = Diagnostic.Kind.ERROR;
+ private static final Diagnostic.Kind DEFAULT_MIN_ALLOWED_MESSAGE_KIND = Diagnostic.Kind.ERROR;
+ private Diagnostic.Kind minAllowedMessageKind = DEFAULT_MIN_ALLOWED_MESSAGE_KIND;
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
@@ -102,7 +103,7 @@ public synchronized void init(ProcessingEnvironment processingEnv) {
GraalVmProcessor.class.getName(),
kindValue,
PluginProcessor.MIN_ALLOWED_MESSAGE_KIND_OPTION,
- Diagnostic.Kind.ERROR,
+ DEFAULT_MIN_ALLOWED_MESSAGE_KIND,
Arrays.toString(Diagnostic.Kind.values())));
}
}
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor.java
index 4896d30dbba..8d2b844091b 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor.java
@@ -97,7 +97,8 @@ public class PluginProcessor extends AbstractProcessor {
private final List processedElements = new ArrayList<>();
private final PluginCache pluginCache = new PluginCache();
- private Diagnostic.Kind minAllowedMessageKind = Diagnostic.Kind.ERROR;
+ private static final Diagnostic.Kind DEFAULT_MIN_ALLOWED_MESSAGE_KIND = Diagnostic.Kind.ERROR;
+ private Diagnostic.Kind minAllowedMessageKind = DEFAULT_MIN_ALLOWED_MESSAGE_KIND;
@Override
public void init(final ProcessingEnvironment processingEnv) {
@@ -114,7 +115,7 @@ public void init(final ProcessingEnvironment processingEnv) {
PluginProcessor.class.getName(),
kindValue,
MIN_ALLOWED_MESSAGE_KIND_OPTION,
- Diagnostic.Kind.ERROR,
+ DEFAULT_MIN_ALLOWED_MESSAGE_KIND,
Arrays.toString(Diagnostic.Kind.values())));
}
}
From 5402ef3791b0821be3be0173ca816fb38ff2a1df Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Volkan=20Yaz=C4=B1c=C4=B1?=
Date: Tue, 15 Sep 2026 16:29:31 +0200
Subject: [PATCH 4/6] Fix documentation
---
.../antora/modules/ROOT/pages/manual/plugins.adoc | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/site/antora/modules/ROOT/pages/manual/plugins.adoc b/src/site/antora/modules/ROOT/pages/manual/plugins.adoc
index a647ef5024a..3f5fe347c0f 100644
--- a/src/site/antora/modules/ROOT/pages/manual/plugins.adoc
+++ b/src/site/antora/modules/ROOT/pages/manual/plugins.adoc
@@ -218,12 +218,11 @@ Provide these values to the processor using the `log4j.graalvm.groupId` and `log
.Suppressing annotation processor notes in strict build environments
[%collapsible]
====
-Some build environments treat all compiler notes or warnings as errors (e.g., Maven with `-Werror` or Gradle with `options.compilerArgs << '-Werror'`).
-By default, `PluginProcessor` and `GraalVmProcessor` emit `NOTE`-level diagnostics when they write their descriptors, which can cause the build to fail in those environments.
-To suppress these informational notes, pass the `log4j.plugin.processor.minAllowedMessageKind` annotation processor option with a value of `WARNING` or `ERROR`.
-This instructs aforementioned processors to only emit diagnostics at or above the specified severity, silencing routine notes while preserving genuine warnings and errors.
+`PluginProcessor` and `GraalVmProcessor` emit `NOTE`-level diagnostics when they write their descriptors.
+To enable these informational notes, pass the `log4j.plugin.processor.minAllowedMessageKind` annotation processor option with a value of less severity than `ERROR`, which is the default.
+This instructs aforementioned processors to only emit diagnostics at or above the specified severity.
-Accepted values (case-insensitive): `NOTE` (default), `WARNING`, `MANDATORY_WARNING`, `ERROR`, `OTHER`.
+Accepted values (case-insensitive): `NOTE`, `WARNING`, `MANDATORY_WARNING`, `ERROR` (default), `OTHER`.
[tabs]
=====
@@ -232,7 +231,7 @@ Maven::
[source,xml]
----
- -Alog4j.plugin.processor.minAllowedMessageKind=WARNING
+ -Alog4j.plugin.processor.minAllowedMessageKind=NOTE
----
@@ -241,7 +240,7 @@ Gradle::
[source,groovy]
----
compileJava {
- options.compilerArgs << '-Alog4j.plugin.processor.minAllowedMessageKind=WARNING'
+ options.compilerArgs << '-Alog4j.plugin.processor.minAllowedMessageKind=NOTE'
}
----
=====
From d1a559ac94ddc0152bfbab29d35dc850fadc4e99 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Volkan=20Yaz=C4=B1c=C4=B1?=
Date: Tue, 15 Sep 2026 16:30:56 +0200
Subject: [PATCH 5/6] Fix Spotless failures
---
.../processor/GraalVmProcessorTest.java | 30 +++++++------------
1 file changed, 11 insertions(+), 19 deletions(-)
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/GraalVmProcessorTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/GraalVmProcessorTest.java
index 650b6f3f707..eb14c49aa97 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/GraalVmProcessorTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/GraalVmProcessorTest.java
@@ -216,14 +216,10 @@ void reachabilityMetadataPath(@Nullable String groupId, @Nullable String artifac
}
@Test
- void whenNoGroupIdAndArtifactId_thenWarningIsEmittedWhenConfigured(@TempDir(cleanup = CleanupMode.NEVER) Path outputDir)
- throws Exception {
+ void whenNoGroupIdAndArtifactId_thenWarningIsEmittedWhenConfigured(
+ @TempDir(cleanup = CleanupMode.NEVER) Path outputDir) throws Exception {
List diagnostics = generateDescriptor(
- sourceDir,
- null,
- null,
- outputDir,
- "-A" + PluginProcessor.MIN_ALLOWED_MESSAGE_KIND_OPTION + "=WARNING");
+ sourceDir, null, null, outputDir, "-A" + PluginProcessor.MIN_ALLOWED_MESSAGE_KIND_OPTION + "=WARNING");
assertThat(diagnostics).hasSize(1);
// The warning message should contain the information about the missing groupId and artifactId arguments
assertThat(diagnostics.get(0))
@@ -247,13 +243,12 @@ void whenNoGroupIdAndArtifactId_thenWarningIsEmittedWhenConfigured(@TempDir(clea
@Test
void noteEmittedWhenConfiguredWithLog4jPrefix(@TempDir Path outputDir) throws Exception {
- List> diagnostics =
- generateDiagnostics(
- sourceDir,
- GROUP_ID,
- ARTIFACT_ID,
- outputDir,
- "-A" + PluginProcessor.MIN_ALLOWED_MESSAGE_KIND_OPTION + "=NOTE");
+ List> diagnostics = generateDiagnostics(
+ sourceDir,
+ GROUP_ID,
+ ARTIFACT_ID,
+ outputDir,
+ "-A" + PluginProcessor.MIN_ALLOWED_MESSAGE_KIND_OPTION + "=NOTE");
assertThat(diagnostics)
.anyMatch(diagnostic -> diagnostic.getKind() == Diagnostic.Kind.NOTE
@@ -264,11 +259,8 @@ void noteEmittedWhenConfiguredWithLog4jPrefix(@TempDir Path outputDir) throws Ex
@Test
void notesSuppressedByDefaultWithoutAffectingMetadataGeneration(@TempDir Path outputDir) throws Exception {
- List> diagnostics = generateDiagnostics(
- sourceDir,
- GROUP_ID,
- ARTIFACT_ID,
- outputDir);
+ List> diagnostics =
+ generateDiagnostics(sourceDir, GROUP_ID, ARTIFACT_ID, outputDir);
assertThat(diagnostics)
.noneMatch(diagnostic -> diagnostic.getKind() == Diagnostic.Kind.NOTE
From 418976ab098a15bc703c940d641fcbb1abf52d3c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Volkan=20Yaz=C4=B1c=C4=B1?=
Date: Thu, 17 Sep 2026 13:34:51 +0200
Subject: [PATCH 6/6] Avoid using custom `printMessage` when inapplicable
---
.../PluginProcessorPublicSetterTest.java | 8 +++++--
.../plugins/processor/GraalVmProcessor.java | 24 ++++++++++++-------
.../plugins/processor/PluginProcessor.java | 24 ++++++++++++-------
3 files changed, 36 insertions(+), 20 deletions(-)
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessorPublicSetterTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessorPublicSetterTest.java
index 0d44f12e9cd..92dacebe240 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessorPublicSetterTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessorPublicSetterTest.java
@@ -155,13 +155,17 @@ void explicitNoteKindEmitsNotes(final String kindValue) {
}
@Test
- void invalidKindValueDoesNotEmitWarningByDefault() {
+ void invalidKindValueEmitsWarning() {
setupWithOptions("-A" + PluginProcessor.MIN_ALLOWED_MESSAGE_KIND_OPTION + "=INVALID");
final List> warningDiagnostics =
diagnosticCollector.getDiagnostics().stream()
.filter(d -> d.getKind() == Diagnostic.Kind.WARNING)
.collect(Collectors.toList());
- assertThat(warningDiagnostics).isEmpty();
+ assertThat(warningDiagnostics)
+ .anyMatch(d -> d.getMessage(Locale.ROOT)
+ .startsWith(
+ "[Log4j] org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor:")
+ && d.getMessage(Locale.ROOT).contains("unrecognized value `INVALID`"));
}
}
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/GraalVmProcessor.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/GraalVmProcessor.java
index 4e27ec94bea..986a13d20ce 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/GraalVmProcessor.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/GraalVmProcessor.java
@@ -96,15 +96,21 @@ public synchronized void init(ProcessingEnvironment processingEnv) {
try {
minAllowedMessageKind = Diagnostic.Kind.valueOf(kindValue.toUpperCase(Locale.ROOT));
} catch (final IllegalArgumentException e) {
- printMessage(
- Diagnostic.Kind.WARNING,
- String.format(
- "%s: unrecognized value `%s` for option `%s`, using default `%s`. Valid values: %s",
- GraalVmProcessor.class.getName(),
- kindValue,
- PluginProcessor.MIN_ALLOWED_MESSAGE_KIND_OPTION,
- DEFAULT_MIN_ALLOWED_MESSAGE_KIND,
- Arrays.toString(Diagnostic.Kind.values())));
+ // We should not use `GraalVmProcessor::printMessage`, since we
+ // report a failure on the user-provided `Diagnostic.Kind` that
+ // `GraalVmProcessor::printMessage` depends on.
+ processingEnv
+ .getMessager()
+ .printMessage(
+ Diagnostic.Kind.WARNING,
+ String.format(
+ "%s%s: unrecognized value `%s` for option `%s`, using default `%s`. Valid values: %s",
+ MESSAGE_PREFIX,
+ GraalVmProcessor.class.getName(),
+ kindValue,
+ PluginProcessor.MIN_ALLOWED_MESSAGE_KIND_OPTION,
+ DEFAULT_MIN_ALLOWED_MESSAGE_KIND,
+ Arrays.toString(Diagnostic.Kind.values())));
}
}
}
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor.java
index 8d2b844091b..8455d66dd5f 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor.java
@@ -108,15 +108,21 @@ public void init(final ProcessingEnvironment processingEnv) {
try {
minAllowedMessageKind = Diagnostic.Kind.valueOf(kindValue.toUpperCase(Locale.ROOT));
} catch (final IllegalArgumentException e) {
- printMessage(
- Diagnostic.Kind.WARNING,
- String.format(
- "%s: unrecognized value `%s` for option `%s`, using default `%s`. Valid values: %s",
- PluginProcessor.class.getName(),
- kindValue,
- MIN_ALLOWED_MESSAGE_KIND_OPTION,
- DEFAULT_MIN_ALLOWED_MESSAGE_KIND,
- Arrays.toString(Diagnostic.Kind.values())));
+ // We should not use `PluginProcessor::printMessage`, since we
+ // report a failure on the user-provided `Diagnostic.Kind` that
+ // `PluginProcessor::printMessage` depends on.
+ processingEnv
+ .getMessager()
+ .printMessage(
+ Diagnostic.Kind.WARNING,
+ String.format(
+ "%s%s: unrecognized value `%s` for option `%s`, using default `%s`. Valid values: %s",
+ MESSAGE_PREFIX,
+ PluginProcessor.class.getName(),
+ kindValue,
+ MIN_ALLOWED_MESSAGE_KIND_OPTION,
+ DEFAULT_MIN_ALLOWED_MESSAGE_KIND,
+ Arrays.toString(Diagnostic.Kind.values())));
}
}
}