java log4j.properties 中的这些属性是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4933707/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 08:39:58  来源:igfitidea点击:

What does these properties in log4j.properties mean?

javalogginglog4j

提问by Anand

log4j.rootCategoryfeild in log4j.properties can have 4 different values namely:

log4j.rootCategorylog4j.properties 中的字段可以有 4 个不同的值,即:

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

DEBUG,WARN,INFO and ERROR. 你能告诉我哪种最适合什么情况吗?

回答by bluish

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.

如果您选择其中之一,log4j 将打印该类型和更严重类型的所有消息。

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*
  • ALL: 打印所有消息*
  • DEBUG: 调试信息
  • INFO: 没有问题的信息
  • WARN: 不是错误,而是可能导致未来错误的东西
  • ERROR: 出现问题,应用程序管理的问题,应用程序可以停止或不停止,通常必须报告
  • FATAL:导致应用程序崩溃的错误
  • OFF: 不打印消息*

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

(*) 这些只是关键字;对于这些类别,没有方法all(msg)off(msg),就像我们有error(msg)或 一样debug(msg)

Usually during development I set to ALLor DEBUG, while when deployed I set to INFOor WARN.

通常在开发过程中我设置为ALLDEBUG,而在部署时我设置为INFOWARN