Provide guarded logger annotation or attribute to the existing @Log4j @Log4j2(guarded = true)
The effect should be that every log.info/debug() invocation should be replaced by respective
if (log.isInfo/DebugEnabled) { log.info/debug() }
Rationale: there's a lot of enterprise code using loggers blindly and producing tons of never logged strings adding a lot of pressure to GC. Suggested approach would fix such behavior. We all know that fixing code is better just not always possible :(
In my experience, guarding is almost never necessary when loggers are used correctly:
There are cases where it may be necessary, but those cases are not those one-liners which could theoretically be guarded by Lombok. So I don't think it's worth the effort (and it's not easy, because Lombok would have to know the method names for all supported logger frameworks).
Disclaimer: I'm not a Lombok team member.
I've explicitly noted that we're not in a perfect world. Majority of enterprise code were written in log4j style. And unless one would love to spend rest of his life fixing broken logging proposed solution adds tremendous value
Most helpful comment
In my experience, guarding is almost never necessary when loggers are used correctly:
There are cases where it may be necessary, but those cases are not those one-liners which could theoretically be guarded by Lombok. So I don't think it's worth the effort (and it's not easy, because Lombok would have to know the method names for all supported logger frameworks).
Disclaimer: I'm not a Lombok team member.