apache / logging-log4j-tools

Tools internally used by the Apache Log4j project
https://logging.apache.org/log4j/tools
Apache License 2.0
14 stars 18 forks source link

Fix plugin subclassing in Log4j Docgen #120

Closed vy closed 6 months ago

vy commented 6 months ago

This change fixes #117, which misses loggers > logger entry.

Why is the entry missing?

log4j-core-plugins.xml contains two entries for LoggerConfig:

  1. <abstractType className="org.apache.logging.log4j.core.config.LoggerConfig">
  2. <plugin name="logger" className="org.apache.logging.log4j.core.config.LoggerConfig">

TypeLookup encounters the <abstractType first and consequently discards the <plugin, hence logger doesn't show up in the LoggerConfig XSD group.

How shall we solve the problem?

If an FQCN is a plugin and is also subclassed by other plugins:

  1. DescriptorGenerator should not generate an AbstractType, but only a PluginType.
  2. TypeLookup should promote an AbstractType to a PluginType if the associated FQCN is later on found to be a plugin. (This can still be the case even after the DescriptorGenerator fix mentioned above. That is, the plugin and the subclassed plugin can be provided in different descriptor files.)