apache / apache/logging-log4j2

XmlConfiguration keeps relevant fields private without providing protected accessors making subclassing difficult

Open
#3,360 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
3.6k
Forks
1.7k
Avg merge
21h 30m
Merged PRs (30d)
27

Description

**Log4j 2.24**

The XmlConfiguration implementation is non-final meaning it is possible to subclass it to provide additional custom functionality; however: the most relevant class field `rootElement` is private making it near impossible to do anything useful in the subclass.

It would be helpful (and prevent making a complete copy of the implementation) to at the very least provide a protected accessor for this field:

i.e. `protected Element getRootElement()`

This way, a custom subclass has a chance to perform some custom handling in `public void setup()` before the hierarchy is constructed.

Most of the AbstractConfiguration configuration-relevant fields are protected (i.e. rootNode) - but it seems someone didn't stick to that approach in the XmlConfiguration implementation.

SIDE NOTE: It seems the complexity of the currrent XmlConfiguration could be greatly reduced by sticking a little more closely to SRP (single-responsibility principle) and offloading the instantiation/configuration of the DocumentBuilderFactory and maybe the validation to separate utility classes .

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.