Skip to content

[main] 3.x plugin validation failure reports valid attributes as invalid #4488

Open

Description

@ramanathan1504

On Log4j 3.x, a plugin element that fails a @Required check is rejected correctly, but then extra ERRORs follow. They report the element's valid attributes as invalid, its child elements as unmatched, and the element itself as unmatched in its parent. This hits any plugin with a required attribute that is left out, whether it is a builder field (File, StringMatchFilter) or a factory-method argument (AppenderRef). Log4j 2.26.1 and current 2.x only log the validation error.

Configuration

Version: 3.0.0-beta3, 3.0.0-alpha1, and current main (not 2.26.1 or current 2.x)
Operating system: macOS
JDK: OpenJDK 17.0.14

Logs

ERROR The parameter is null or empty: fileName
ERROR Could not configure plugin element File: org.apache.logging.log4j.plugins.validation.ConstraintValidationException: Validation failed for fileName (source: private java.lang.String org.apache.logging.log4j.core.appender.FileAppender$Builder.fileName) and value null
ERROR File contains invalid attributes "name", "append", "immediateFlush"
ERROR appender File has no field or parameter that matches element PatternLayout
ERROR No text provided for StringMatchFilter: text
ERROR Could not configure plugin element StringMatchFilter: org.apache.logging.log4j.plugins.validation.ConstraintValidationException: Validation failed for text (source: private java.lang.String org.apache.logging.log4j.core.filter.StringMatchFilter$Builder.text) and value null
ERROR StringMatchFilter contains invalid attributes "onMatch", "onMismatch"
ERROR Console contains an invalid element or attribute "bogusAttr"
ERROR Skipping null child object with name File in element Appenders
ERROR Appenders has no field or parameter that matches element File
ERROR Appender references must contain a reference: ref
ERROR Could not configure plugin element AppenderRef: org.apache.logging.log4j.plugins.validation.ConstraintValidationException: Validation failed for ref (source: final java.lang.String ref) and value null
ERROR AppenderRef contains an invalid element or attribute "level"
ERROR Skipping null child object with name AppenderRef in element Logger
ERROR Logger has no field or parameter that matches element AppenderRef

(The StringMatchFilter lines are from current main. Only bogusAttr is a real invalid attribute. On 2.26.1 the same configuration logs the validation errors, the bogusAttr line and Null object returned for File in Appenders., and nothing else.)

Reproduction

<Configuration status="WARN">
  <Appenders>
    <File name="NoFileName" append="false" immediateFlush="true">
      <PatternLayout pattern="%m%n"/>
    </File>
    <RandomAccessFile name="Host" fileName="target/host.log" append="false">
      <PatternLayout pattern="%m%n"/>
      <StringMatchFilter onMatch="DENY" onMismatch="NEUTRAL"/>
    </RandomAccessFile>
    <Console name="Typo" bogusAttr="1">
      <PatternLayout pattern="%m%n"/>
    </Console>
  </Appenders>
  <Loggers>
    <Logger name="noref" level="INFO" additivity="false">
      <AppenderRef level="DEBUG"/>
    </Logger>
    <Root level="INFO">
      <AppenderRef ref="Host"/>
    </Root>
  </Loggers>
</Configuration>

Run any program that calls LogManager.getLogger(...) with -Dlog4j.configuration.location=log4j2.xml (log4j-api 2.24.3 with log4j-core 3.0.0-beta3). Every contains invalid attributes and has no field or parameter line other than the one for bogusAttr names an attribute or element that is valid.

Activity

  1. changed the title [-]3.x plugin validation failure reports valid attributes as invalid[/-] [+][main] 3.x plugin validation failure reports valid attributes as invalid[/+] on Nov 16, 2026
  2. added
    bug
    plugins
    priority: P3
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpluginspriority: P3

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions