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?
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.
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.
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.
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 messagesINFO
: information that aren't problemsWARN
: not error but something that could cause a future errorERROR
: something went wrong, a problem that the application manages, the application could be stopped or not, usually must be reportedFATAL
: an error that crashes the applicationOFF
: 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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With