Log4j is a JavaSW library that specializes in logging. At the time of this writing, its home page is at http://logging.apache.org/log4j/docs/ . The Java library itself is available for download at http://logging.apache.org/site/binindex.cgi . The short manual at http://logging.apache.org/log4j/docs/manual.html does a great job covering many of the standard features of Log4j. At its most basic level, you can think of it as a replacement for System.out.println's in your code. Why is it better than System.out.println's? The reasons are numerous.
To begin with, System.out.println outputs to standard output, which typically is a console window. The output from Log4j can go to the console, but it can also go to an email server, a databaseW table, a log file, or various other destinations.
Another great benefit of Log4j is that different levels of logging can be set. The levels are hierarchical and are as follows: TRACE, DEBUG, INFO, WARN, ERROR, and FATAL. If you set a particular log level, messages will get logged for that level and all levels above it, and not for any log levels below that. As an example, if your log level is set to ERROR, you will log messages that are errors and fatals. If your log level is set to INFO, you will log messages that are infos, warns, errors, and fatals. Typically, when you develop on your local machine, it's good to set the log level to DEBUG, and when you deploy a web application, you should set the log level to INFO or higher so that you don't fill up your error logs with debug messages.
Here are some of the screenshots:
http://www.avajava.com/tutorials/lessons/what-is-log4j-and-how-do-i-use-it.html
No comments:
Post a Comment