Add log4j2 annotation processor so packages is not required
See original GitHub issueCurrently it’s necessary to pass the packages
attributes via <Configuration packages="io.prometheus.client.log4j2">
in log4j configuration to discover the appender.
That means relying on step 5 of https://logging.apache.org/log4j/2.x/manual/plugins.html for appender discovery (analyzing packages and annotations at startup).
It would seem less error prone and more efficient to add the log4j annotation processor to the Maven compiler plugin, so it builds the metadata META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat at build time (step1) ?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Log4j2 (2.1) custom plugin not detected by packages attribute
I am following the solution but not sure how plugin dat file created for custom plugin or where exactly I need to make...
Read more >Configuring Log4j 2 - Apache Logging Services
Configuration. Inserting log requests into the application code requires a fair amount of planning and effort.
Read more >Log4j 2 Tutorial: Configuration Example for Logging in Java
Discover how to configure and use appenders, filters, layouts, and levels for logging your ... The not-so-full list of appenders in Log4j 2:....
Read more >Log4j2 Example Tutorial - Configuration, Levels, Appenders
journaldev is absent and so no logging might have happened at com.journaldev package and the event would be propagated for com and Root....
Read more >Log4j 2 Plugins - Baeldung
A comma-separated list of packages can be added in the Log4j 2 configuration file. As a prerequisite, annotation processing must be enabled to ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for looking into this. So it looks like (2) is not a problem.
However, (1) sounds like this would break existing builds if users create uber-JARs but didn’t configure the
log4j-transformer
plugin. I imagine fixing the build will be non-trivial in some cases. Many frameworks like Spring inherit the Maven shade plugin from a parent POM, and it is not straightforward where to put thelog4j-transformer
plugin configuration.Good points, here’s what I’ve found: