Log4j: Difference between revisions
| Line 12: | Line 12: | ||
#it always exists, | #it always exists, | ||
#it cannot be retrieved by name, but by Logger.getRootLogger(). | #it cannot be retrieved by name, but by Logger.getRootLogger(). | ||
==Priority== | ==Priority== | ||
| Line 26: | Line 22: | ||
* FATAL | * FATAL | ||
Priority objects have both a string name and an integer value. The name is simply a mnemonic label for the priority. The integer value defines a relative order amongst priorities. The Level class extends the Priority class to be conform with java.util.logging. For the standard levels, we have DEBUG < INFO < WARN < ERROR < FATAL. | Priority objects have both a string name and an integer value. The name is simply a mnemonic label for the priority. The integer value defines a relative order amongst priorities. The Level class extends the Priority class to be conform with java.util.logging. For the standard levels, we have DEBUG < INFO < WARN < ERROR < FATAL. | ||
==Category== | |||
A category is a like java named entity. There exists a special root category that simply is, but has no name. | |||
=Configuration= | =Configuration= | ||
Revision as of 21:54, 26 January 2012
Concepts
Log4j has teh following fundamental objects:
- logger
- categories,
- priorities (levels),
- appenders and
- layouts.
Logger
Loggers are named entities. Logger names are case-sensitive and they follow the hierarchical naming rule. A logger is said to be an ancestor of another logger if its name followed by a dot is a prefix of the descendant logger name. The root logger resides at the top of the logger hierarchy. It is exceptional in two ways:
- it always exists,
- it cannot be retrieved by name, but by Logger.getRootLogger().
Priority
Loggers may be assigned levels. The set of possible levels, that is:
- TRACE
- DEBUG
- INFO
- WARN
- ERROR
- FATAL
Priority objects have both a string name and an integer value. The name is simply a mnemonic label for the priority. The integer value defines a relative order amongst priorities. The Level class extends the Priority class to be conform with java.util.logging. For the standard levels, we have DEBUG < INFO < WARN < ERROR < FATAL.
Category
A category is a like java named entity. There exists a special root category that simply is, but has no name.
Configuration
Properties can be defined by a properties file or by an XML file. The xml configuration class offers more flexibility and the benefits, and drawbacks, of an XML based configuration.
Logging Level are:
- ALL
- DEBUG
- ERROR
- FATAL
- INFO
- OFF
- TRACE
- WARN