You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "ppkarwasz (via GitHub)" <gi...@apache.org> on 2026/06/26 11:48:28 UTC

[PR] Revamp XML configuration testing and documentation [logging-log4j2]

ppkarwasz opened a new pull request, #4155:
URL: https://github.com/apache/logging-log4j2/pull/4155

   This PR reworks how the XML configuration format is tested and documented so that each behavior of the DOM-to-`Node` conversion in `XmlConfiguration` is covered by its own focused test. Doing so surfaced a small attribute-handling bug, fixed here.
   
   ## Testing
   
   - `constructHierarchy`, `getType` and `processAttributes` are now `static` and take the `PluginManager` and `strict` flag as parameters, so the DOM-to-`Node` conversion can be unit-tested with a mocked `PluginManager` instead of spinning up a full `LoggerContext`.
   - The `StrictXmlConfigTest` integration test (which only asserted event counts and merely happened to exercise strict-mode parsing) is replaced by `XmlConfigurationConstructHierarchyTest`, covering individually: plugin resolution, attribute folding, text-as-value, strict-mode `type` resolution, and XInclude whole-file / positional `element()` / by-`name` (`ID`) fragment resolution.
   - The unused `Status`/`ErrorType` bookkeeping is dropped in favor of logging the error directly.
   
   ## Bug fix
   
   - The XInclude `fixup-language` feature adds an `xml:lang` attribute to included elements that was never stripped (only `xml:base` was) and was not covered by any test, so it leaked through as a Log4j configuration attribute. `processAttributes` now matches the reserved XML namespace instead of the literal attribute name, stripping `xml:base`, `xml:lang`, and any other reserved `xml:` attribute.
   - `XmlConfiguration` no longer explicitly enables the `fixup-base-uris`/`fixup-language` features: they default to `true` and only
     add attributes Log4j strips (they are not required for nested or relative includes to resolve).
   
   ## Documentation
   
   - The XML format section of `configuration.adoc` is moved into a reusable AsciiDoc partial (`partials/manual/configuration-xml-format.adoc`).
   - The XInclude docs gain a section about including fragments with positional and by-`name` XPointer examples, plus a note that the JDK does not recognize `xml:id` and does not implement the `xpointer()` scheme.
   
   There is no behavior change for valid configurations; the only runtime difference is that `xml:lang` no longer leaks into the configuration.
   
   ## Checklist
   
   * [x] Based on `2.x`
   * [ ] `./mvnw verify` succeeds (only the affected modules were tested locally)
   * [x] Changelog entry in `src/changelog/.2.x.x`
   * [x] Tests provided
   


-- 
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-unsubscribe@logging.apache.org

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


Re: [PR] Revamp XML configuration testing and documentation [logging-log4j2]

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz merged PR #4155:
URL: https://github.com/apache/logging-log4j2/pull/4155


-- 
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-unsubscribe@logging.apache.org

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