Menu

#1189 GuardLogStatementRule and GuardDebugLoggingRule broken for log4j2

New Tickets
more-info-needed
None
PMD
1-Blocker
Bug
5.1.0
2014-07-15
2014-04-21
Terje
No

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.

Discussion

  • Andreas Dangel

    Andreas Dangel - 2014-04-26

    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?

     
  • Andreas Dangel

    Andreas Dangel - 2014-04-26
    • status: open --> more-info-needed
    • assigned_to: Andreas Dangel
     
  • Andreas Dangel

    Andreas Dangel - 2014-07-15

    There seems to be an additional issue, see bug [#1224]

     

    Related

    Issues: #1224


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.