当前位置:   article > 正文

spring boot引入logback.xml

spring boot引入logback.xml

logback.xml

  1. <configuration>
  2. <property name="LOG_PATTERN" value="%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n" />
  3. <property name="FILE_PATH" value="D:/logs/course03/demo.%d{yyyy-MM-dd}.%i.log" />
  4. <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
  5. <encoder>
  6. <!-- 按照上面配置的LOG_PATTERN来打印日志 -->
  7. <pattern>${LOG_PATTERN}</pattern>
  8. </encoder>
  9. </appender>
  10. <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
  11. <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  12. <!-- 按照上面配置的FILE_PATH路径来保存日志 -->
  13. <fileNamePattern>${FILE_PATH}</fileNamePattern>
  14. <!-- 日志保存15天 -->
  15. <maxHistory>15</maxHistory>
  16. <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
  17. <!-- 单个日志文件的最大,超过则新建日志文件存储 -->
  18. <maxFileSize>10MB</maxFileSize>
  19. </timeBasedFileNamingAndTriggeringPolicy>
  20. </rollingPolicy>
  21. <encoder>
  22. <!-- 按照上面配置的LOG_PATTERN来打印日志 -->
  23. <pattern>${LOG_PATTERN}</pattern>
  24. </encoder>
  25. </appender>
  26. <logger name="com.yfy.springboot" level="INFO" />
  27. <root level="INFO">
  28. <appender-ref ref="CONSOLE" />
  29. <appender-ref ref="FILE" />
  30. </root>
  31. </configuration>

yml中引入文件

  1. logging:
  2. config: classpath:logback.xml
  3. level:
  4. com:
  5. yfy:
  6. springboot:
  7. dao : debug

level后面是dao层的目录,配置控制台输出sql

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/595092
推荐阅读
相关标签