views:

78

answers:

3

I am soon going to use log4j class using Java, for a project, to create logs. But i dont think i know or have any slightest idea about it. Hope someone enlightens me over this, but, trivial issue.

+3  A: 

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/

Caladain
+2  A: 

You should start by looking at the log4j documentation and FAQ, then come back and ask questions when you run into a specific problem.

Bill the Lizard
+2  A: 

Log4j is very easy to use. Try the manual.

Also lots of people use commons logging to wrapper log4j, if you are sure you want to use log4j for the long term then use it directly.

You should also get agreement within your development team what logging levels mean what to your org, for example TRACE & DEBUG are pretty easy. But often people dont have standards as when to use INFO vs WARN vs ERROR. Also what should happen when a log entry of a certain level happens. I like to look at it from the operators point of view, when you see a log level of "FATAL" what do you do? or of "ERROR" etc.

Joelio