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
What does these properties in log4j.properties mean?
提问by Anand
log4j.rootCategory
feild in log4j.properties can have 4 different values namely:
log4j.rootCategory
log4j.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 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*
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 ALL
or DEBUG
, while when deployed I set to INFO
or WARN
.
通常在开发过程中我设置为ALL
或DEBUG
,而在部署时我设置为INFO
或WARN
。