怎么解决引用slf4j中Logger.info没有数据的问题(logger.info,slf4j,开发技术)

时间:2024-05-09 19:37:20 作者 : 石家庄SEO 分类 : 开发技术
  • TAG :

    %E6%80%8E%E4%B9%88%E8%A7%A3%E5%86%B3%E5%BC%95%E7%94%A8slf4j%E4%B8%ADLogger.info%E6%B2%A1%E6%9C%89%E6%95%B0%E6%8D%AE%E7%9A%84%E9%97%AE%E9%A2%98

引的是 slf4j 包

只能打印出:

2019-06-14 17:52:07.246 [http-apr-8080-exec-10] INFO c.q.m.p.b.rest.test - 打印参数:

在第一个参数中加入花括号{ }即可。

解决!

在resouces目录下面新建logback.xml(此为Logback推荐目录)

内容配置如下

logback 分为两种设置:

1. 输出到控制台 STDOUT

2. 输出到文件 FILE

下面的配置同时配置输出到文件和输出到控制台

1.申明 logger 变量

2.在程序中调用日志

官方介绍网址:https://logback.qos.ch/demo.html

下面为官网介绍

logback-classic with two appenders: a ConsoleAppender and a RollingFileAppender. The RollingFileAppender sends logging events to a file called logFile.log and will rollover the active file every minute. The old file will be renamed and compressed to a zip file. The ConsoleAppender will output the logging requests to the console, and shorten the logger names to gain space on the console window, without loss of legibility. For example, ch.qos.logback.demo.prime.NumberCruncherImpl will be abbreviated as c.q.l.d.prime.NumberCruncherImpl.

输出结果如下

isDebugEnabled true
2017-04-23 23:58:35,502 DEBUG [http-nio-8080-exec-6] (LoginLogDao.java:32) - INSERT INTO t_login_log(user_id,ip,login_datetime) VALUES(?,?,?)
2017-04-23 23:58:35,503 DEBUG [http-nio-8080-exec-6] (JdbcTemplate.java:869) - Executing prepared SQL update
2017-04-23 23:58:35,503 DEBUG [http-nio-8080-exec-6] (JdbcTemplate.java:616) - Executing prepared SQL statement [INSERT INTO t_login_log(user_id,ip,login_datetime) VALUES(?,?,?)]

本文:怎么解决引用slf4j中Logger.info没有数据的问题的详细内容,希望对您有所帮助,信息来源于网络。
上一篇:Android Studio如何集成OpenCV下一篇:

6 人围观 / 0 条评论 ↓快速评论↓

(必须)

(必须,保密)

阿狸1 阿狸2 阿狸3 阿狸4 阿狸5 阿狸6 阿狸7 阿狸8 阿狸9 阿狸10 阿狸11 阿狸12 阿狸13 阿狸14 阿狸15 阿狸16 阿狸17 阿狸18