ppkarwasz commented on issue #2769:
URL:
https://github.com/apache/logging-log4j2/issues/2769#issuecomment-3050376973
Hi @snicoll,
Thanks for reaching out.
> Does this change force us to make the builder public?
No, you’re not required to make the builder public. If you’d prefer to keep
it package-private, you can suppress the warning using:
```java
@SuppressWarnings("log4j.public.setter")
@PluginBuilderAttribute
private String name;
```
That said, we do recommend making Log4j plugins and their builders `public`,
for a few reasons:
* **JPMS Compatibility**: In a Java Platform Module System (JPMS)
environment, reflection on `public` members in exported packages works out of
the box. In contrast, accessing `package-private` or `private` members requires
opening the package, which defeats the purpose of encapsulating the plugin
internals.
* **Reducing DI Complexity**: Starting in Log4j 3.x, we’ve introduced a
lightweight [dependency injection
framework](https://logging.apache.org/log4j/3.x/javadoc/log4j-plugins/index.html).
While it’s intentionally minimal and not intended to replace Spring’s IoC
container, it has grown increasingly complex due to needing to support various
reflective access patterns. By enforcing `public` setters, we can streamline
the implementation and reduce the need for advanced reflection handling.
* **Future Improvements**: Looking ahead, we plan to generate configuration
classes at build time to improve startup performance. Public, well-structured
plugins and builders are much easier to use for this purpose.
Certainly! Here's a clearer and more polished version of your note, with
improved tone, structure, and flow:
### Note
Since you're working on Spring Boot's compatibility with Log4j 2.25.0
(spring-projects/spring-boot#46334), you may be interested in the [Log4j 2.25.1
release
candidate](https://github.com/apache/logging-log4j2/discussions/3766#discussioncomment-13671473).
This release primarily addresses integration issues with Spring Boot and other
environments.
Although the formal voting period has technically ended, I can keep it open
for a couple more days to give you time to verify that everything works as
expected on your end—hopefully avoiding the need for a follow-up `2.25.2`
release shortly after. Let me know what you think.
--
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]