ramanathan1504 opened a new issue, #4488:
URL: https://github.com/apache/logging-log4j2/issues/4488
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
```xml
<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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]