Re: Is the Checkstyle project interested in a Log4J Best Practice checker?

Klaus-Peter Berg <[email protected]> Thu, 18 Dec 2008 02:11:56 -0800 (PST)
Newsgroups gmane.comp.java.audit.checkstyle.user
Message-ID <[email protected]>
Up to now one check (module) does it all, but the "log-and-propagate" check
can be enabled or disabled.

Slf4j's parametric logging, as with "LOGGER.debug("value1={}, value2={}",
value1, value2);", will NOT be flagged as a Checkstyle error/warning. The
same is true for "LOGGER.debug("message string only")."
But "LOGGER.debug("message text"  + object);" would be flagged as
"LOGGER.debug(...) call not surrounded by if (...)", i.e., the check is
missing the "if (LOGGER.isDebugEnabled())" statement prior to the actual
logging call.



Great!

I am wondering about a couple of things, if you don't mind me asking...

Are these individual checks, or one check that does all?  (I am wondering if
we can disable one or more)

With the "Avoid using parameter construction within the logging request"
check, does it work with Slf4j's parametric logging?

    LOGGER.debug("value1={}, value2={}", value1, value2);

That log message must not fail the check with Slf4j (Slf4j does not call
toString() on the message parameters (value1, value2) if the level is not
active), as the message is a constant and the check should handle the
additional parameters. 


-- 
View this message in context: http://www.nabble.com/Is-the-Checkstyle-project-interested-in-a-Log4J-Best-Practice-checker--tp20910513p21069931.html
Sent from the CheckStyle - User mailing list archive at Nabble.com.


------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/