Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpringBoot automatic configuration is invalid #1898

Open
129duckflew opened this issue Sep 18, 2024 · 0 comments
Open

SpringBoot automatic configuration is invalid #1898

129duckflew opened this issue Sep 18, 2024 · 0 comments
Labels

Comments

@129duckflew
Copy link

I used SpringBoot to automatically configure the Starter and did not observe the expected default logs.

Description

According to the documentation, I imported the following dependencies (version=3.9.0)

<dependency>
<groupId>org.zalando</groupId>
<artifactId>logbook-spring-boot-starter</artifactId>
<version>${logbook.version}</version>
</dependency>

The SpringBoot version I am using is 3.2.5
The following is my SpringBoot default configuration file application.yaml

logbook:
  filter:
    enabled: true
logging:
  config: classpath:logback-dev.xml
  level:
    org:
      zalando:
        logbook: trace

The following is my logback-dev configuration file

<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds">

<contextName>rms</contextName>


<property name="LOG_HOME" value="/var/log/attence"/>


<property name="PATTERN"
value="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%X{traceId}][%X{username}] [%thread] %logger{30}:%line - %msg%n"/>

<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
<conversionRule conversionWord="wex"
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
<conversionRule conversionWord="wEx"
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
<property name="CONSOLE_LOG_PATTERN"
value="%d{yyyy-MM-dd HH:mm:ss.SSS} %yellow([%X{traceId}][%X{username}]) %highlight(%-5level) %magenta(%logger{30}:%-3L) - %m%n"/>

<property name="CONSOLE_LOG_PATTERN_SIMPLE"
value="%d{HH:mm:ss.SSS} %highlight(%-5level) %magenta(%logger{20}:%-3L) - %m%n"/>

<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>DEBUG</level>
</filter>
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
<charset>utf-8</charset>
</encoder>
</appender>

<appender name="RollingFile"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>DEBUG</level>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/%d{yyyy-MM-dd}.log
</fileNamePattern>
<maxHistory>180</maxHistory>
<totalSizeCap>10GB</totalSizeCap>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${PATTERN}</pattern>
<charset>utf-8</charset>
</encoder>
</appender>
<appender name="AsyncRollingFile" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="RollingFile"/>
<includeCallerData>true</includeCallerData>
</appender>

<logger name="org.mybatis" level="INFO"/>
<logger name="org.springframework" level="INFO"/>
<logger name="org.apache" level="WARN"/>
<logger name="org.zalando.logbook" level="TRACE"/>
<root level="INFO">
<appender-ref ref="Console"/>
<appender-ref ref="AsyncRollingFile"/>
</root>
</configuration>

When I switch the log level of the Spring Framework to DEBUG, I find that the beans related to logbook are correctly loaded.

2024-09-18 13:57:51.644 [][] DEBUG o.s.b.f.s.DefaultListableBeanFactory:225 - Creating shared instance of singleton bean 'logbookFilter'
2024-09-18 13:57:51.644 [][] DEBUG o.s.b.f.s.DefaultListableBeanFactory:225 - Creating shared instance of singleton bean 'org.zalando.logbook.autoconfigure.LogbookAutoConfiguration$JakartaServletFilterConfiguration'
2024-09-18 13:57:51.645 [][] DEBUG o.s.b.f.s.DefaultListableBeanFactory:225 - Creating shared instance of singleton bean 'logbook-org.zalando.logbook.autoconfigure.LogbookProperties'
2024-09-18 13:57:51.647 [][] DEBUG o.s.b.f.s.DefaultListableBeanFactory:945 - Autowiring by type from bean name 'org.zalando.logbook.autoconfigure.LogbookAutoConfiguration$JakartaServletFilterConfiguration' via constructor to bean named 'logbook-org.zalando.logbook.autoconfigure.LogbookProperties'
2024-09-18 13:57:51.648 [][] DEBUG o.s.b.f.s.DefaultListableBeanFactory:225 - Creating shared instance of singleton bean 'logbook'
2024-09-18 13:57:51.648 [][] DEBUG o.s.b.f.s.DefaultListableBeanFactory:225 - Creating shared instance of singleton bean 'org.zalando.logbook.autoconfigure.LogbookAutoConfiguration'
2024-09-18 13:57:51.648 [][] DEBUG o.s.b.f.s.DefaultListableBeanFactory:945 - Autowiring by type from bean name 'org.zalando.logbook.autoconfigure.LogbookAutoConfiguration' via constructor to bean named 'logbook-org.zalando.logbook.autoconfigure.LogbookProperties'


Expectation

I believe this issue isn't necessarily a bug, but rather a potential oversight on my part during usage. I've consulted numerous minimal demos and official documentation, yet I haven't been able to find a solution. My expectation is for the request log to be correctly outputted to the console.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant