码迷,mamicode.com
首页 > 编程语言 > 详细

Java Logging: Log Levels

时间:2015-06-16 01:10:37      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:

Table of Contents

When a message is logged via a Logger it is logged with a certain log level. The built-in log levels are:

  • SEVERE
  • WARNING
  • INFO
  • CONFIG
  • FINE
  • FINER
  • FINEST

The log level is represented by the class java.util.logging.Level. This class contains a constant for each of the above log levels. It is one of these constants you use when you log a message to a Logger. Here is an example:

logger.log(Level.SEVERE, "A severe message!");

Filtering Messages

You can filter the messages by their log level, meaning you can configure a Logger to not log, and not propagate messages below a certain level. Here is an example of that:

logger.setLevel(Level.WARNING);

The Logger now ignores all messages below the log level WARNING.

To understand how log levels behave in the Logger hierarchy, check out the text on the Logger hierarchy.

Java Logging: Log Levels

标签:

原文地址:http://www.cnblogs.com/hephec/p/4579624.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!