SpringBoot默认日志配置

 时间:2024-10-31 11:38:36

1、编写一个junit测试类,用来打印springboot日志。package com.gwolf;import org.junit.Test;import org.junit.runner.RunWith;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.boot.test.context.SpringBootTest;import org.springframework.test.context.junit4.SpringRunner;@RunWith(SpringRunner.class)@SpringBootTestpublic class SpringBoot01HelloQuickApplicationTests { Logger logger = LoggerFactory.getLogger(this.getClass()); @Test public void contextLoads() { this.logger.trace("这个trace日志..."); this.logger.debug("这个debug日志..."); this.logger.info("这个info日志..."); this.logger.warn("这个warn日志..."); this.logger.error("这个error日志..."); }}

SpringBoot默认日志配置

2、执行junti日志测试类,查看日志的执行结果。从日志答应的结果来看,只显示了info级别以上的日志。springboot默认给我们使用的info级别的,没有指定级别的就用springboot默认规定的级别。

SpringBoot默认日志配置

3、修改application.properties日志级别。server.port=8081logging.level.com.gwolf=trace

SpringBoot默认日志配置

4、springboot中可以指定日志的记录文件。server.port=8081logging.level.com.gwolf=tracelogg足毂忍珩ing.file=springboot.log不指定路径就是在当前项目下生成日志。

SpringBoot默认日志配置

5、可以通过指定logging.path在当前磁盘的根路径下创建spring文件夹和里面的log文件夹。logging.path=/spring/log

SpringBoot默认日志配置SpringBoot默认日志配置
  • 【oracle开发】视图、索引及 约束
  • MSSQL数据库测试连接的快捷方法
  • Eclipse安装maven插件配置本地仓库
  • oracle导入dmp文件问题
  • 基于Qt5 Quick的多媒体播放器制作
  • 热门搜索
    成长足迹手抄报内容 心理手抄报 三年级的手抄报 可爱的中国手抄报 寻访红色足迹手抄报 手抄报边框大全 手抄报花 传统文化手抄报大全 感恩老师的手抄报图片 小学安全知识手抄报