What does these properties in log4j.properties mean?

a 夏天 提交于 2019-12-10 13:25:29

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/4933707/what-does-these-properties-in-log4j-properties-mean

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!