Log4j basically takes any statement you want to output, lets you assign a "severity" level to it (warning, error, critical, etc) and logs it out in a variety of ways. (to a file, to a byte stream, etc. there are lots of appender options available.);
Here's a short blurb introduction to log4j.
http://www.developer.com/open/article.php/3097221/Logging-with-log4jmdashAn-Efficient-Way-to-Log-Java-Applications.htm
Here's a short tutorial:
http://veerasundar.com/blog/2009/07/log4j-tutorial-adding-log4j-logging-to-your-project/