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

Java之Logger日志(Java8特性)

时间:2018-05-23 18:03:44      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:ati   get   parse   level   特性   style   消息   final   eve   

 

 1 import java.util.logging.Level;
 2 import java.util.logging.Logger;
 3 
 4 public class LoggingDemo {
 5     public static final Logger logger = Logger.getLogger("LoggingDemo.class");
 6 
 7     public static void main(String args[]) {
 8         Level level = Level.parse("FINEST");
 9         logger.info(level.toString());
10 
11         //下面的消息将被输出
12         logger.setLevel(level);
13         logger.info("this is an info");
14         logger.warning("this is a warn");
15         logger.severe("this is a severe");
16 //        logger.config("config");
17 //        logger.fine("fine");
18 //        logger.finer("finer");
19 //        logger.finest("finest");
20 
21         logger.info("LoggerName: " + logger.getName());
22         logger.info("LoggerLevelName: " + logger.getLevel().getName());
23 
24     }
25 }

运行结果:

五月 23, 2018 5:13:24 下午 org.study2.java8.logging.LoggingDemo main
信息: FINEST
五月 23, 2018 5:13:24 下午 org.study2.java8.logging.LoggingDemo main
信息: this is an info
五月 23, 2018 5:13:24 下午 org.study2.java8.logging.LoggingDemo main
警告: this is a warn
五月 23, 2018 5:13:24 下午 org.study2.java8.logging.LoggingDemo main
严重: this is a severe
五月 23, 2018 5:13:24 下午 org.study2.java8.logging.LoggingDemo main
信息: LoggerName: LoggingDemo.class
五月 23, 2018 5:13:24 下午 org.study2.java8.logging.LoggingDemo main
信息: LoggerLevelName: FINEST

 

Java之Logger日志(Java8特性)

标签:ati   get   parse   level   特性   style   消息   final   eve   

原文地址:https://www.cnblogs.com/gongxr/p/9077925.html

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