【spring boot 学习笔记】日志相关
1. 如何启用日志?
maven依赖中添加:
spring-boot-starter-logging
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>实际开发中我们不需要直接添加该依赖。 你会发现
spring-boot-starter
其中包含了spring-boot-starter-logging
,该依赖内容就是Spring Boot
默认的日志框架logback。例如:spring-boot-starter-thymeleaf。
此外,spring-boot-starter 核心Spring Boot starter,包括自动配置支持,日志和YAML等。
2. spring boot 默认日志
默认采用的日志是slf4j+logback,其他框架或者第三方库会通过jul-to-slf4j,log4j-to-slf4j等桥接库,将其日志重定向到slf4j,进而采用logback打印输出。
你可能需要排除其他框架或者第三方库的原来使用的日志实现(因为他们可能在他们的pom依赖中添加了编译/打包范围的日志实现依赖(例如:log4j2,springboot的starter组件配置依赖时默认排除了springboot框架使用的common-logging日志框架)。
3. 需不需要修改默认日志
不需要,强烈建议,除非有不可抗拒的原因(不会有的,别想了)。
4. spring boot 如何自定义日志配置项
常用选项:
logging.exception-conversion-word LOG_EXCEPTION_CONVERSION_WORD The conversion word used when logging exceptions. logging.file LOG_FILE If defined, it is used in the default log configuration. logging.file.max-size LOG_FILE_MAX_SIZE Maximum log file size (if LOG_FILE enabled). (Only supported with the default Logback setup.) logging.file.max-history LOG_FILE_MAX_HISTORY Maximum number of archive log files to keep (if LOG_FILE enabled). (Only supported with the default Logback setup.) logging.path LOG_PATH If defined, it is used in the default log configuration. logging.pattern.console CONSOLE_LOG_PATTERN The log pattern to use on the console (stdout). (Only supported with the default Logback setup.) logging.pattern.dateformat LOG_DATEFORMAT_PATTERN Appender pattern for log date format. (Only supported with the default Logback setup.) logging.pattern.file FILE_LOG_PATTERN The log pattern to use in a file (if LOG_FILE is enabled). (Only supported with the default Logback setup.) logging.pattern.level LOG_LEVEL_PATTERN The format to use when rendering the log level (default %5p). (Only supported with the default Logback setup.)
【spring boot 学习笔记】日志相关的更多相关文章
- Spring Boot学习笔记2——基本使用之最佳实践[z]
前言 在上一篇文章Spring Boot 学习笔记1——初体验之3分钟启动你的Web应用已经对Spring Boot的基本体系与基本使用进行了学习,本文主要目的是更加进一步的来说明对于Spring B ...
- Spring Boot 学习笔记(六) 整合 RESTful 参数传递
Spring Boot 学习笔记 源码地址 Spring Boot 学习笔记(一) hello world Spring Boot 学习笔记(二) 整合 log4j2 Spring Boot 学习笔记 ...
- spring boot学习笔记2
开场知识: spring 容器注入bean,时容器初始化的一些接口以及接口调用的时间先后顺序: 1)BeanFactoryPostProcessor 容器初始化的回调方法 * BeanFactoryP ...
- Spring Boot 学习笔记1——初体验之3分钟启动你的Web应用[z]
前言 早在去年就简单的使用了一下Spring Boot,当时就被其便捷的功能所震惊.但是那是也没有深入的研究,随着其在业界被应用的越来越广泛,因此决定好好地深入学习一下,将自己的学习心得在此记录,本文 ...
- Spring Boot 学习笔记1---初体验之3分钟启动你的Web应用
前言 早在去年就简单的使用了一下Spring Boot,当时就被其便捷的功能所震惊.但是那是也没有深入的研究,随着其在业界被应用的越来越广泛,因此决定好好地深入学习一下,将自己的学习心得在此记录,本文 ...
- 我的第一个spring boot程序(spring boot 学习笔记之二)
第一个spring boot程序 写在前面:鉴于spring注解以及springMVC的配置有大量细节和知识点,在学习理解之后,我们将直接进入spring boot的学习,在后续学习中用到注解及其他相 ...
- Spring Boot 学习笔记一(SpringBoot启动过程)
SpringBoot启动 Spring Boot通常有一个名为*Application的入口类,在入口类里有一个main方法,这个main方法其实就是一个标准的java应用的入口方法. 在main方法 ...
- Spring Boot学习笔记二
Spring Boot入门第二篇 第一天的详见:https://www.cnblogs.com/LBJLAKERS/p/12001253.html 同样是新建一个pring Initializer快速 ...
- Spring Boot学习笔记一
Spring Boot简介 前言:本章简单介绍Spring boot的使用. (第二天springboot的学习之路:https://www.cnblogs.com/LBJLAKERS/p/12003 ...
随机推荐
- 关于eclipse设置JRebel
版本:eclipse ee Version: 2018-09 (4.9.0) jrebel:最新2019-2 1.在eclipse->help->eclipse Marketplace 2 ...
- 【洛谷p1051】谁拿了最多奖学金
谁拿了最多奖学金[题目链接] 这道题早就想做它啦. 咱也不知道为啥,咱就是看这道题特别顺眼呢qwq: MY SOLUTION: 其实这道题很简单,开一个结构体记录各项信息,然后根据条件计算出这个人获得 ...
- 【洛谷p1781】宇宙总统
宇宙总统[题目链接] 关于题目算法,其实就是考排序,那我们直接sort不就好啦,显然不能. 这个题让我重新认识了cmp函数: 以下是我的心路历程: 看到这个题,嗯?这么简单的吗,我直接sort不就好啦 ...
- 常用的框架伪静态(Apache转Nginx)
EmpireCMS: rewrite ^([^\.]*)/listinfo-(.+?)-(.+?)\.html$ $/e/action/ListInfo/index.php?classid=$& ...
- .net几种timer区别
概述:.net框架不同名称控件都包含了各种timer,但每个timer有什么具体区别呢? 一.System.Threading private static void ThreadingTimer() ...
- node.js 设置静态文件托管
1.在app.js文件中设置静态文件托管 /*应用程序入口文件*/ /*加载express模块*/ var express = require('express'); /*加载模板处理模块*/ var ...
- java复习(3)继承下
一.抽象类 ------------------------------------- 1.抽象定义概述:抽象类时从多个事物中奖共性的,本质的内容抽取出来 例如:狼和狗共性都是犬科,犬科就是抽象出来的 ...
- flutter-dart语言初识
dart 官方文档 http://dart.goodev.org/guides/language/language-tour# 重要概念所以能够使用变量引用的都是对象,也就是所以可以赋值给变量的都是对 ...
- git ssh 绑定 GitLab
入职新公司之后,需要使用GitLab,可是我不会啊,又不想麻烦运维大佬,所以自己找乐一下,发现网上都是些很陈旧的教程,所以准备自己记录下来 第一步 设置Git端上的用户名和用户邮箱: 假如入你已经安装 ...
- Codeforces 909 substr用法 思维合并线段目标最少 Py语句逆推DP vecrtor缩点删不同颜色点模拟 拓扑排序处理任务
A str.substr(i,j) 从str[i]开始起取j个字符作为返回的字符串 /* Huyyt */ #include <bits/stdc++.h> using namespace ...