For those that are wondering about the need for a logging utility in their project when there are already debuggers, you might want to read the following passage from the book "The Practice of Programming":
To add log4j to your project, first you will have to download it to your lib folder in your project. Make sure to add it to your classpath. If you are using Eclipse, just right click on the jar file in the lib directory, and go to Build Path -> Add to Build Path.
This tutorial is going to cover configuring log4j via a properties file called "log4j.properties". Configuring can also be done with a different technique using XML.
It is considered a good coding practice to include your log4j.properties file in a "config" directory.
Another library that we will be using for the purpose of this tutorial is the DatedFileAppender library.
As personal choice, we tend not to use debuggers beyond getting a stack trace or the value of a variable or two. One reason is that it is easy to get lost in details of complicated data structures and control flow; we find stepping through a program less productive than thinking harder and adding output statements and self-checking code at critical places. Clicking over statements takes longer than scanning the output of judiciously-placed displays. It takes less time to decide where to put print statements than to single-step to the critical section of code, even assuming we know where that is. More important, debugging statements stay with the program; debugging sessions are transient.Log4j is a Java-based logging utility and is a project of the Apache Software Foundation.
To add log4j to your project, first you will have to download it to your lib folder in your project. Make sure to add it to your classpath. If you are using Eclipse, just right click on the jar file in the lib directory, and go to Build Path -> Add to Build Path.
This tutorial is going to cover configuring log4j via a properties file called "log4j.properties". Configuring can also be done with a different technique using XML.
It is considered a good coding practice to include your log4j.properties file in a "config" directory.
Another library that we will be using for the purpose of this tutorial is the DatedFileAppender library.