JWT007 opened a new issue, #3478:
URL: https://github.com/apache/logging-log4j2/issues/3478

   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);
      }
    }
   ```
   


-- 
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: notifications-unsubscr...@logging.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to