Instead of System.out.println()
, use a logging framework.
There are several logging frameworks that are used for Java projects. Log4J is probably the most well-known and popular one. My first choice would be SLF4J, which is actually not a logging framework itself, but a layer which you use to which you can plug-in different logging frameworks (such as Log4J or Logback).
There's also a standard logging framework in the standard Java API, in the package java.util.logging
, but in my experience it isn't very popular.
Advantages of using a logging framework instead of System.out.println()
calls are that you can easily configure the logging to write to a file or some other storage instead of to the console, and that you can use different logging levels for debugging, warnings, and errors, and you can choose what level of log output you want to get.