iis服务器助手广告广告
返回顶部
首页 > 资讯 > 精选 >spring boot 日志配置详解
  • 277
分享到

spring boot 日志配置详解

springboot日志 2023-05-31 16:05:39 277人浏览 薄情痞子
摘要

最近在学习Spring Boot框架的路上,今日看了一下spring boot日志配置,顺便留个笔记记录一下。新建logback.xml文件 内容如下:<!-- Logback configuration. See Http

最近在学习Spring Boot框架的路上,今日看了一下spring boot日志配置,顺便留个笔记记录一下。

新建logback.xml文件

spring boot 日志配置详解 

内容如下:

<!-- Logback configuration. See Http://logback.qos.ch/manual/index.html --><configuration scan="true" scanPeriod="10 seconds"> <include resource="org/springframework/boot/logging/logback/base.xml" /> <appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">  <File>${LOG_PATH}/info.log</File>  <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">   <fileNamePattern>${LOG_PATH}/info-%d{yyyyMMdd}.log.%i</fileNamePattern>   <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">    <maxFileSize>500MB</maxFileSize>   </timeBasedFileNamingAndTriggeringPolicy>   <maxHistory>2</maxHistory>  </rollingPolicy>  <layout class="ch.qos.logback.classic.PatternLayout">   <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n   </Pattern>  </layout> </appender> <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">  <filter class="ch.qos.logback.classic.filter.ThresholdFilter">   <level>ERROR</level>  </filter>  <File>${LOG_PATH}/error.log</File>  <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">   <fileNamePattern>${LOG_PATH}/error-%d{yyyyMMdd}.log.%i   </fileNamePattern>   <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">    <maxFileSize>500MB</maxFileSize>   </timeBasedFileNamingAndTriggeringPolicy>   <maxHistory>2</maxHistory>  </rollingPolicy>  <layout class="ch.qos.logback.classic.PatternLayout">   <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n   </Pattern>  </layout> </appender>  <!-- hibernate日志输入 --> <!-- <logger name="org.hibernate.type.descriptor.sql.BasicBinder"  level="TRACE" /> <logger name="org.hibernate.type.descriptor.sql.BasicExtractor"  level="TRACE" /> <logger name="org.hibernate.SQL" level="INFO" /> <logger name="org.hibernate.engine.QueryParameters" level="INFO" /> <logger name="org.hibernate.engine.query.HQLQueryPlan" level="INFO" /> --> <root level="INFO">  <appender-ref ref="INFO_FILE" />  <appender-ref ref="ERROR_FILE" /> </root> </configuration>

--结束END--

本文标题: spring boot 日志配置详解

本文链接: https://www.lsjlt.com/news/227225.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • spring boot 日志配置详解
    最近在学习spring boot框架的路上,今日看了一下spring boot日志配置,顺便留个笔记记录一下。新建logback.xml文件 内容如下:<!-- Logback configuration. See http...
    99+
    2023-05-31
    spring boot 日志
  • 基于Spring Boot的Logback日志轮转配置详解
    在生产环境下,日志是最好的问题调试和跟踪方法,因此日志的地位是十分重要的。我们平时经常使用的log4j,slf4j,logback等等,他们的配置上大同小异。这里就结合Spring Boot配置一下Logback的日志。默认最简单的配置默认...
    99+
    2023-05-31
    springboot logback 日志
  • 详解Spring Boot实现日志记录 SLF4J
    在开发中打印内容,使用 System.out.println() 和 Log4j 应当是人人皆知的方法了。 其实在开发中我们不建议使用 System.out 因为大量的使用 System.out 会增加资源的消耗。 而Log4j 更为灵活在...
    99+
    2023-05-31
    spring boot slf4j
  • 使用Spring Boot如何对日志进行配置
    这篇文章给大家介绍使用Spring Boot如何对日志进行配置,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。默认日志 Logback :默认情况下,Spring Boot会用Logback来记录日志,并用INFO级别输...
    99+
    2023-05-31
    springboot spring boo
  • Spring Boot的Profile配置详解
    Profile 是Spring Boot用来针对不同的环境对不同的配置提供的支持,全局Profile配置使用application-{profile}.properties,如: application-dev.properties 可以表...
    99+
    2023-05-31
    spring boot profile
  • 在spring boot项目中如何配置日志管理
    这篇文章将为大家详细讲解有关在spring boot项目中如何配置日志管理,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。spring Boot在所有内部日志中使用Commons Loggin...
    99+
    2023-05-31
    springboot 目中 日志
  • Spring Boot Redis 集成配置详解
    spring Boot 熟悉后,集成一个外部扩展是一件很容易的事,集成Redis也很简单,看下面步骤配置:一、添加pom依赖 <dependency> <groupId>org.springframe...
    99+
    2023-05-31
    spring boot redis
  • 详解Spring Boot 配置多个RabbitMQ
    闲话好久没有写博客了,6月份毕业,因为工作原因,公司上网受限,一直没能把学到的知识点写下来,工作了半年,其实学到的东西也不少,但是现在回忆起来的东西少之又少,有时甚至能在同个问题中踩了几次,越来越觉得及时记录一下学到的东西很重要。好了,闲话...
    99+
    2023-05-31
    spring boot rabbitmq
  • 【Java】Spring Boot 日志文件
    文章目录 SpringBoot日志文件1. 日志有什么用2. 日志怎么用3. 自定义日志打印3.1 在程序中得到日志对象3.2 使用日志对象打印日志 4. 日志级别4.1 日志级别有什么...
    99+
    2023-09-23
    java spring boot spring
  • spring boot Slf4j日志框架的体系结构详解
    目录前言一、五花八门的日志工具包1.1. 日志框架1.2.日志门面1.3日志门面存在的意义二、日志框架选型三、日志级别四、常见术语概念解析总结前言 刚刚接触到java log日志的同...
    99+
    2024-04-02
  • spring boot 配置动态刷新详解
    本文测试使用的springcloud版本为: Dalston.SR1 很多朋友只知道springcloudconfig可以刷新远程git的配置到内存中, 却不知道springclou...
    99+
    2024-04-02
  • spring boot中的properties参数配置详解
    application.propertiesapplication.properties是spring boot默认的配置文件,spring boot默认会在以下两个路径搜索并加载这个文件src\main\resourcessrc\main...
    99+
    2023-05-31
    spring boot properties
  • 详解在spring boot中配置多个DispatcherServlet
    spring boot为我们自动配置了一个开箱即用的DispatcherServlet,映射路径为‘/',但是如果项目中有多个服务,为了对不同服务进行不同的配置管理,需要对不同服务设置不同的上下文,比如开启一个DispatcherServl...
    99+
    2023-05-31
    spring boot 配置
  • 在Spring Boot中使用slf4j与logback如何实现配置日志
    这期内容当中小编将会给大家带来有关在Spring Boot中使用slf4j与logback如何实现配置日志,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。spring boot主要的目的是:为 Spring...
    99+
    2023-05-31
    springboot slf4j logback
  • 详解spring-boot actuator(监控)配置和使用
    在生产环境中,需要实时或定期监控服务的可用性。spring-boot 的actuator(监控)功能提供了很多监控所需的接口。简单的配置和使用如下:1、引入依赖:<dependency> <groupId>org...
    99+
    2023-05-31
    spring boot actuator
  • Spring Boot 使用 HikariCP 连接池配置详解
    Spring Boot 使用 HikariCP 连接池配置详解 HikariCP 是一个高性能的 JDBC 连接池组件。 Spring Boot 2.x 将其作为默认的连接池组件,项目中添加 spring-boot-starter-jdbc...
    99+
    2023-08-18
    mybatis mysql java spring boot
  • Spring Boot + Jpa(Hibernate) 架构基本配置详解
    基于springboot-1.4.0.RELEASE版本测试springBoot + hibernate + Druid + MySQL + servlet(jsp)不废话,直接上代码一、maven的pom文件<?xml ve...
    99+
    2023-05-31
    spring boot jpa
  • Spring boot Thymeleaf配置国际化页面详解
    目录1.编写多语言国际化配置文件2.编写配置文件3.定制区域信息解析器4.页面国际化使用5.整合效果测试1.编写多语言国际化配置文件 在项目的类路径resources下创建名称为i1...
    99+
    2024-04-02
  • 详解Spring Boot中如何自定义SpringMVC配置
    目录前言一、SpringBoot 中 SpringMVC 配置概述二、WebMvcConfigurerAdapter 抽象类三、WebMvcConfigurer 接口四、WebMvc...
    99+
    2024-04-02
  • 详解Spring Boot中使用AOP统一处理Web请求日志
    在spring boot中,简单几步,使用spring AOP实现一个拦截器:1、引入依赖:<dependency> <groupId>org.springframework.boot</groupId&g...
    99+
    2023-05-31
    spring boot aop
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作