Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does these properties in log4j.properties mean?

log4j.rootCategory feild in log4j.properties can have 4 different values namely:

DEBUG,WARN,INFO and ERROR. Can you tell me which is most suitable for what cases?

like image 820
Anand Avatar asked Feb 08 '11 13:02

Anand


People also ask

What are log4j properties?

The log4j. properties file is a log4j configuration file which stores properties in key-value pairs. The log4j properties file contains the entire runtime configuration used by log4j. This file will contain log4j appenders information, log level information and output file names for file appenders.

Is log4j properties required?

rootLogger property sets the Level (DEBUG here) and Appender (A1 here) for root Logger. This is not mandatory. Root logger does not have a default appender attached and it can exist without an appender.

What are the three most important components of log4j?

log4j has three main components: loggers: Responsible for capturing logging information. appenders: Responsible for publishing logging information to various preferred destinations. layouts: Responsible for formatting logging information in different styles.


1 Answers

From the least severe to the most one:

ALL < DEBUG < INFO < WARN < ERROR < FATAL < OFF

If you choose one of them log4j will print all messages of that type and of more severe type.

Purposes:

  • ALL: prints all messages*
  • DEBUG: debug messages
  • INFO: information that aren't problems
  • WARN: not error but something that could cause a future error
  • ERROR: something went wrong, a problem that the application manages, the application could be stopped or not, usually must be reported
  • FATAL: an error that crashes the application
  • OFF: prints no messages*

(*) these are only keywords; for these categories there are no methods all(msg) and off(msg), like we have error(msg) or debug(msg).

Usually during development I set to ALL or DEBUG, while when deployed I set to INFO or WARN.

like image 166
bluish Avatar answered Nov 15 '22 18:11

bluish