We are migrating to log4j version 2 and are using GuardDebugLoggingRule. Up to and including 5.0.5 this works well with the new Log4j version 2 API.
However, starting with 5.1.0, the following code causes a false postive:
final Marker m = MarkerManager.getMarker(mymarker);
if (logger.isTraceEnabled(m)) {
logger.debug(m, message);
}
Could it be that the new XPath introduced in 5.1.0 for this rule does not take into account that the .isXxxxxEnabled() method may have a parameter?
Since we use PMD aggressively and fail the build on any violation, this is a blocker for us to use version 5.1.0 and the new JDK 8 support.
I verified this rule and it works with and without the extra argument.
In your code sample, you are guarding the
debug(...)
call with trace - and that's the reason, why the rule triggers.Could you please check, if you fix this, whether the violations are resolved then?
There seems to be an additional issue, see bug [#1224]
Related
Issues:
#1224