ppkarwasz commented on PR #1276:
URL: https://github.com/apache/logging-log4j2/pull/1276#issuecomment-1432946158
@adwsingh,
In #1231 I was thinking about something slightly different. There are two
ways to instantiate a Log4j2 component like `IfLastModified`:
* you can call `IfLastModified#createAgeCondition` in your code. We don't
recommend such a programmatic approach, so if you pass `null` as `age`
parameter, IMHO you deserve the NPE with a standard message,
* you can declare it in your configuration. In such a case the component is
instantiated by
[`PluginBuilder`](https://logging.apache.org/log4j/2.x/log4j-core/apidocs/org/apache/logging/log4j/core/config/plugins/util/PluginBuilder.html)
that validates all constraints and logs the validation errors appropriately.
I think that the path conditions just lack an appropriate
[`@Required`](https://logging.apache.org/log4j/2.x/log4j-core/apidocs/org/apache/logging/log4j/core/config/plugins/validation/constraints/Required.html)
annotation on those parameters that are required.
We also have some complex constraints that are not supported by
`PluginBuilder`: e.g. `IfFileName` requires a glob **or** a regex. To deal with
this case `IfFileName#createNameCondition` should check if exactly one of
`glob` and `regex` is `null`. If this is not the case the method should log an
error (`StatusLogger`) and return `null`.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]