log4j.properties中的这些属性是什么意思?[英] What does these properties in log4j.properties mean?

本文是小编为大家收集整理的关于log4j.properties中的这些属性是什么意思?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

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

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

推荐答案

从最不严重到最严重:

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

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

目的:

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

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

通常在开发期间我设置为 ALL 或 DEBUG,而在部署时我设置为 INFO 或 WARN.

本文地址:https://www.itbaoku.cn/post/1574993.html

问题描述

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?

推荐答案

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.