[
https://issues.apache.org/jira/browse/LOG4J2-3691?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17889180#comment-17889180
]
Piotr Karwasz commented on LOG4J2-3691:
---------------------------------------
Hi [~JWT007],
Given your use case, you might probably be interested in our new born:
[log4j-docgen|https://logging.apache.org/log4j/tools/log4j-docgen.html]. It is
a small tool that scans the {{@Plugin*}} annotated elements of our source code
and creates a plugin descriptor like [this
stub|https://github.com/apache/logging-log4j-tools/blob/main/log4j-docgen/src/main/resources/org/apache/logging/log4j/docgen/generator/base-log4j-types.xml].
Currently we use this tool internally to:
* generate plugin descriptors in the {{target/plugin-descriptors}} folder of
our build. These files currently are not published, but you can obtain them by
[building Log4j from
source|https://github.com/apache/logging-log4j2/blob/2.x/BUILDING.adoc].
* generate and publish an [up-to-date XML
schema|https://logging.apache.org/xml/ns/].
* generate and publish a [plugin
reference|https://logging.apache.org/log4j/2.x/plugin-reference.html]. Unlike
our manual, this contains all the configuration parameters for a Log4j Plugin.
The {{log4j-docgen}} artifact is based on
[Modello|https://codehaus-plexus.github.io/modello/] and contains all the code
to serialize and deserialize plugin descriptors. The format of the plugin
descriptor is *strongly inspired* by [Maven plugin
descriptors|https://maven.apache.org/ref/3.9.9/maven-plugin-api/plugin.html]
and we plan to extend it in that direction. Although the development of
{{log4j-docgen}} is currently on pause with [a couple of unresolved
issues|https://github.com/apache/logging-log4j-tools/issues] (while we
concentrate on other aspects of Log4j before we run out of funding ;) ), feel
free to propose improvements to it.
Regarding the conversion of runtime components into an XML configuration, that
was always problematic and we also encounter it on a regular basis in our unit
tests. One of the possible solutions I discussed with [~vy] in the past would
be to introduce a {{toBuilder()}} method to our components that transforms the
component into a Java Bean containing all the information about the
configuration. That might be a solution to your problem.
> Documentation: CompositeTriggeringPolicy - nested <Policies> element?
> ---------------------------------------------------------------------
>
> Key: LOG4J2-3691
> URL: https://issues.apache.org/jira/browse/LOG4J2-3691
> Project: Log4j 2
> Issue Type: Bug
> Components: Configuration, Documentation
> Affects Versions: 2.24.0
> Reporter: Jeff Thomas
> Priority: Minor
>
> According to my JetBrains AI Assistant :):
> "According to the Log4j 2 configuration guidelines, nesting a {{Policies}}
> element within another {{Policies}} element is not supported. Each
> {{RollingFile}} appender should have one {{Policies}} element, which in turn,
> directly contains the individual policies."
> Example:
> {code:java}
> <RollingFile name="FILE"
> fileName="app.log"
> filePattern="app.%d{yyyy-MM-dd}.%i.log">
> <JsonTemplateLayout/>
> <Policies>
> <OnStartupTriggeringPolicy/>
> <Policies>
> <SizeBasedTriggeringPolicy/>
> <TimeBasedTriggeringPolicy/>
> </Policies>
> </Policies>
> </RollingFile> {code}
> I could not find an explicit statement regarding this in the new Log4j 2.x
> documentation.
> Also in the code of the `CompositeTriggeringPolicy` class it seems that there
> is no validation check to ensure that this does not happen.
> If this is in fact, undesirable maybe the documentation should state this and
> also enforce it in code (or alternatively aggregate the policies - flatten
> them to the top-level).
> Side note: the documentation and implementation don't mention adding multiple
> policies of the same type to a composite-policy (i.e. two
> "CronTriggeringPolicy" elements) - whether this is supported or actively
> discouraged.
> NOTE: The same question could be applied to the `CompositeFilter`constructor
> not checking if one of the provided filters is also a `CompositeFilter`.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)