Open
Description
Log4j 2.24.3
.----
The DefaultPropertyComponentBuilder
does not generate a valid Property Component.
A Log4j XML configuration property should look like this:
<Property name="p1" value="foobar"/>
However, if the ConfigurationBuilder.newProperty("p1", "foobar")
is called, it generates a ComponentBuilder
equivalent to this.
<Property name="p1">foobar</Property>
This is because in the PropertyComponentBuilder
constructor here:
public DefaultPropertyComponentBuilder(final DefaultConfigurationBuilder<? extends Configuration> builder, final String name, final String value) {
super(builder, name, "Property", value);
}
... the value
gets passed to the super method as the element content value and not as the value
attribute.
Correct would probably be:
public DefaultPropertyComponentBuilder(final DefaultConfigurationBuilder<? extends Configuration> builder, final String name, final String value) {
super(builder, name, "Property", null);
if (value != null) {
this.addAttribute("value", value);
}
}
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
To triage