Menu

#1335 GuardLogStatementJavaUtil should not apply to SLF4J Logger

PMD-5.3.2
closed
None
PMD
3-Major
Bug
5.2.1
2015-05-01
2015-04-09
No

The GuardLogStatementJavaUtil rule fires for every log event for an org.slf4j.Logger instance -- but since SLF4J Logger's intentionally do lazy evaluation on the logging statements, adding guards is not necessary.

This rule should not apply to org.slf4j.Logger instances.

Related

Issues: #1347

Discussion

  • Andreas Dangel

    Andreas Dangel - 2015-05-01

    This will be fixed with PMD 5.3.2 (commit: https://github.com/pmd/pmd/commit/a0d116ca6d205a1ef65bbf02c50ceec84277a2f7)

    The rule will ignore any classes, which import something from slf4j. Please note, that your statement is only true, if you use message parameters ("{}") - otherwise you would fall back to string concatenation and this would be done before calling the log method - and then a guard would be necessary.

     
  • Andreas Dangel

    Andreas Dangel - 2015-05-01
    • status: open --> closed
    • assigned_to: Andreas Dangel
    • Milestone: New Tickets --> PMD-5.3.2
     

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.