-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DefaultPropertyComponentBuilder generates invalid "Property" Component #3478
Comments
@ppkarwasz can you assign to me and I will try and get a PR ready on the weekend |
The two configurations below are equivalent: <Property name="p1" value="foobar"/>
<Property name="p1">foobar</Property> I don't believe there is anything wrong in the way |
@ppkarwasz - ahh I see now that the @PluginValue annotation (PluginValueVisitor) first checks the value and then the attribute. I was looking at the code and compared it to the plugin documentatiion. Its probably OK then - was just expecting the PropertyComponentBuilder to generate as documented. |
@ppkarwasz by the way, KeyValuePairComponentBuilder handles it differently.
|
Since XML elements can have attributes, nested elements and text content, the XML configuration format offers some flexibility on how to specify configuration attributes. In our manual we try to use a "canonical" form, but it is not always consistent. Two Log4j plugins can have text content: <Property name="foo" value="bar"/> but for the second we use a CDATA node: <Script name="EVENT_LOGGER_FILTER" language="groovy"><![CDATA[
return logEvent.getMarker() != null && logEvent.getMarker().isInstanceOf("FLOW");
]]></Script> However, this is a personal style choice, I am not sure if we should align |
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 aComponentBuilder
equivalent to this.<Property name="p1">foobar</Property>
This is because in the
PropertyComponentBuilder
constructor here:... the
value
gets passed to the super method as the element content value and not as thevalue
attribute.Correct would probably be:
The text was updated successfully, but these errors were encountered: