When i run my PMD plugin they say System.out.println
has been used. why is System.out.println
bad to use and is it a defect when using PMD plugin? and what is the alternative way of over coming this?
System.out.println..
are usually intended for debugging purposes and can remain in the codebase even in production code. By using a logger one can enable/disable this behaviour at will (and by priority) and avoid clogging the Standard out log.
(from SourceMeter Java user guide under "Java Logging Rules")
Import needed (.jar)
Example:
import org.apache.log4j.Logger;
class Foo{
private static final Logger LOG = Logger.getLogger(Foo.class);
public void testA () {
System.out.println("Entering test");
// Better use this
LOG.info("Entering test");
}
}