博客
关于我
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系列之锁机制
查看>>
Mysql系列九:使用zookeeper管理远程Mycat配置文件、Mycat监控、Mycat数据迁移(扩容)...
查看>>
Mysql索引
查看>>
mysql索引
查看>>
mysql索引
查看>>
Mysql索引,索引的优化,如何避免索引失效案例
查看>>
Mysql索引、命令重点介绍
查看>>
mysql索引、索引优化(这一篇包括所有)
查看>>
MySQL索引一篇带你彻底搞懂(一次讲清实现原理加优化实战,面试必问)
查看>>
MySQL索引下沉:提升查询性能的隐藏秘
查看>>
MySql索引为什么使用B+树
查看>>
WARNING!VisualDDK wizard was unable to find any DDK/WDK installed on your system.
查看>>
Mysql索引优化
查看>>
MySQl索引创建
查看>>
mysql索引创建及使用注意事项
查看>>
mysql索引创建和使用注意事项
查看>>
MySQL索引原理以及查询优化
查看>>
Mysql索引合并(index merge)导致的死锁问题
查看>>
mysql索引底层数据结构和算法
查看>>
Mysql索引底层结构的分析
查看>>