lukaszspyra commented on issue #1231: URL: https://github.com/apache/logging-log4j2/issues/1231#issuecomment-1581059851
Hi, I came across this issue and looked through the comments on the [closed PR ]( #1276 ). I would like to contribute, however I have question regarding the previous conversation: >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. From what I noticed, at least in case of IfLastModified#createAgeCondition there is no builder defined, so in both ways to instantiate it (pragmatic and PluginBuilder) it would fall to the same factory method. Adding `@Required` on the param will result in logging error in any way (followed by NPE from Objects.requiredNonNull() of private c-tor), there would be no distinction. Is it acceptable solution? -- 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]
