static analysis - What's wrong with using System.err in Java? -


I'm using your Java code Enerjy () static code analyzer tool it tells me that the following line: < / P>

System.err.println ("That database was ignored");

Bad because it uses System.err is the exact error: "Use of JAVA0267 System.err"

What is wrong with using System.err?

It is an observation that in the old time when no widely available / acceptable entry frameworks, everyone used to print error messages and stack marks in the system err. This approach may be suitable during the development and local testing phase but is not suitable for the production environment, because you can lose important error messages, due to this, today such code has been detected in almost all static analysis tools And it has been marked as a poor practice (or similarly named problem).

The logging frameworks provide a structured and logical way to enter in return, in the form of events and error messages, they can store messages in various constant locations (log files, log db, etc.).

The most obvious (and external reliance-free) hack resolution is created in the Java logging framework through the java.util.logging.Logger class Because it bypasses the logging events in the console by default. For example:

  last logger log = logger.gatelogger (getclass (.) GetName ()); ... log.log (level error, "something went wrong", expansion);  

(or you can turn off that analysis option)


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -