博客
关于我
Springboot2模块系列:日志slf4j2(持久化)
阅读量:244 次
发布时间:2019-03-01

本文共 2063 字,大约阅读时间需要 6 分钟。

1 pom.xml

排除springboot默认的日志框架,使用slf4j2日志框架作为持久化工具。

org.springframework.boot
spring-boot-starter
org.springframework.boot
spring-boot-starter-logging
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-logging
org.springframework.boot
spring-boot-starter-log4j2

2 slf4j2.xml

日志持久化配置:设置日志级别error,warn和info以及保存日志路径。

ddd
logs/${app_name}

3 application.yml

引入日志配置文件。

logging:  level:     root: info  config: classpath:config/slf4j2.xml

4 Usage

使用slf4j作为日志输出工具。

4.1 生成日志

import org.slf4j.Logger;import org.slf4j.LoggerFactory;public class LoggerSave{   	static Logger logger = LoggerFactory.getLogger(LoggerSave.class);	public void main(String[] args){   		logger.error("error test");	}}

【参考文献】

[1]
[2]
[3]
[4]
[5]
[6]

转载地址:http://hvht.baihongyu.com/

你可能感兴趣的文章
MySQL底层概述—1.InnoDB内存结构
查看>>
MySQL底层概述—2.InnoDB磁盘结构
查看>>
MySQL底层概述—3.InnoDB线程模型
查看>>
MySQL底层概述—4.InnoDB数据文件
查看>>
MySQL底层概述—5.InnoDB参数优化
查看>>
MySQL底层概述—6.索引原理
查看>>
MySQL底层概述—7.优化原则及慢查询
查看>>
MySQL底层概述—8.JOIN排序索引优化
查看>>
MySQL底层概述—9.ACID与事务
查看>>
Mysql建立中英文全文索引(mysql5.7以上)
查看>>
mysql建立索引的几大原则
查看>>
Mysql建表中的 “FEDERATED 引擎连接失败 - Server Name Doesn‘t Exist“ 解决方法
查看>>
mysql开启bin-log日志,用于canal同步
查看>>
MySQL开源工具推荐,有了它我卸了珍藏多年Nactive!
查看>>
MySQL异步操作在C++中的应用
查看>>
MySQL引擎讲解
查看>>
Mysql当前列的值等于上一行的值累加前一列的值
查看>>
MySQL当查询的时候有多个结果,但需要返回一条的情况用GROUP_CONCAT拼接
查看>>
MySQL必知必会(组合Where子句,Not和In操作符)
查看>>
MySQL必知必会总结笔记
查看>>