博客
关于我
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管理利器 MySQL Utilities 安装
查看>>
MySQL篇(管理工具)
查看>>
mysql类型转换函数convert与cast的用法
查看>>
mysql系列一
查看>>
MySQL系列之数据授权(安全)
查看>>
MySQL系列之数据类型(Date&Time)
查看>>
MySQL系列之数据类型(Date&Time)
查看>>
Mysql系列之锁机制
查看>>
Mysql系列九:使用zookeeper管理远程Mycat配置文件、Mycat监控、Mycat数据迁移(扩容)...
查看>>
MySql系列:[4200][1140]In aggregated query without GROUP BY, expression #2 of SELECT list contains nona
查看>>
MySQL索引
查看>>
Mysql索引
查看>>
mysql索引
查看>>
mysql索引
查看>>
Mysql索引,索引的优化,如何避免索引失效案例
查看>>
Mysql索引、命令重点介绍
查看>>
mysql索引、索引优化(这一篇包括所有)
查看>>
Mysql索引一篇就够了
查看>>
MySQL索引一篇带你彻底搞懂(一次讲清实现原理加优化实战,面试必问)
查看>>