开发者

What does rootCategory in log4j.properties mean?

开发者 https://www.devze.com 2023-02-09 11:47 出处:网络
log4j.rootCa开发者_如何学运维tegory field in log4j.properties can have 4 different values, namely: DEBUG, WARN, INFO and ERROR.

log4j.rootCa开发者_如何学运维tegory field in log4j.properties can have 4 different values, namely: DEBUG, WARN, INFO and ERROR.

Can you tell me which is most suitable for which cases?


From the least severe to the most one:

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

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

Purposes:

  • ALL: generates 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: generates 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
    • logging on file to ALL or DEBUG
  • when deployed I set
    • logging on file to INFO or WARN
    • logging via email to ERROR
0

精彩评论

暂无评论...
验证码 换一张
取 消