spring-boot(5) 的logback 整理
spring-boot
spring-projects/spring-boot: 是一个用于简化Spring应用开发的框架。适合用于需要快速开发企业级Java应用的项目。特点是可以提供自动配置、独立运行和内置的Tomcat服务器,简化Spring应用的构建和部署。
项目地址:https://gitcode.com/gh_mirrors/sp/spring-boot

·
spring-boot默认支持logback,所以无需引用任何以来只需要,配置application.properties即可,如果要功能丰富些,则配置下logback.xml,如下有三个方法可以选择
一,要输出日志
只要在application.properties里配置
logging.file=./springboot.log
就可以了
这是最简便的方法,默认级别是info,要改级别的话还要在appliacation.properties里增加一行 logging.level.org.springframework.web=DEBUG
二,配置logback.xml
如果是logback.xml
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml" />
<logger name="org.springframework.web" level="DEBUG" />
</configuration>
application.properties
logging.file=./springboot.log
的组合,则也会在产生文件在springboot.log,跟第一个方法的效果是一样的,所以第二种没必要使用
三,只配置logback.xml这个可以在必要是时候使用
<configuration>
<!-- %m输出的信息,%p日志级别,%t线程名,%d日期,%c类的全名,,,, -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<charset>UTF-8</charset>
<pattern>%d %p (%file:%line\)- %m%n</pattern>
</encoder>
</appender>
<appender name="baselog"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/base.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/base.log.%d</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>
%d,%m%n
</pattern>
</encoder>
</appender>
<root level="info">
<appender-ref ref="STDOUT" />
</root>
<logger name="com.bao" level="info">
<appender-ref ref="baselog" />
</logger>
</configuration>




spring-projects/spring-boot: 是一个用于简化Spring应用开发的框架。适合用于需要快速开发企业级Java应用的项目。特点是可以提供自动配置、独立运行和内置的Tomcat服务器,简化Spring应用的构建和部署。
最近提交(Master分支:16 天前 )
1cd14c96
Prior to this commit, Spring Boot would use Framework's
`Jackson2ObjectMapperBuilder` to configure the `ObjectMapper` instance.
This builder would configure the `ProblemDetail` mixin automatically.
With the introduction of Jackson 3.x support, Spring Framework removed
its builder in favor of the native Jackson builder. As a result, the
mixin is not registered with the `JsonMapper` aymore.
This commit ensures that the mixin is registered if the `ProblemDetail`
class is present in the classpath.
Closes gh-47298
2 小时前
51b606e9 - 2 小时前
更多推荐
所有评论(0)