gpt4 book ai didi

spring-boot - LOGBACK : No context given for c. q.l.core.rolling.SizeAndTimeBasedRollingPolicy@1162810564

转载 作者:行者123 更新时间:2023-12-05 00:42:38 27 4
gpt4 key购买 nike

我得到标题上的错误:LOGBACK:没有为 c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@1162810564 提供上下文

添加后,我使用 spring boot 应用程序的最新版本获取它:logging.file.name =src/main/resources/logs/spring advance.log对于工作正常的 application.properties 我只是不明白为什么以及 Logback 是什么意思,如果这是错误/警告?以及如何解决?

如果我不将日志保存到日志文件而只在控制台上打印它,我不会收到此错误

这是我的完整 application.properties:

spring.datasource.url=jdbc:mysql://localhost:3306/example? 
createDatabaseIfNotExist=true&serverTimezone=IST
spring.datasource.username=root
spring.datasource.password=1234
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

#Hibernate/Jpa Configuration:
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
#spring.jpa.properties.hibernate.show_sql:true
#spring.jpa.properties.hibernate.format_sql=true

#Log Configuration:
logging.file.name =src/main/resources/logs/spring advance.log
#•Show Sql Statement:
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type=TRACE
#•Show Sql Values:
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
logging.pattern.file=%d{yyyy-MM-dd HH:mm:ss} - %msg%n
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} - %msg%n

#Server Port Configuration:
server.port=8080

最佳答案

您应该包含 xml 配置文件并在您的 application.properties 中指向它

logging.config=classpath:config/logback-spring.xml

这是我使用的配置文件:

    <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration>
<configuration scan="true">
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<logger name="javax.activation" level="WARN"/>
<logger name="javax.mail" level="WARN"/>
<logger name="javax.management.remote" level="WARN"/>
<logger name="javax.xml.bind" level="WARN"/>
<logger name="ch.qos.logback" level="WARN"/>
<logger name="com.codahale.metrics" level="WARN"/>
<logger name="com.ryantenney" level="WARN"/>
<logger name="com.sun" level="WARN"/>
<logger name="com.zaxxer" level="WARN"/>
<logger name="io.undertow" level="WARN"/>
<logger name="io.undertow.websockets.jsr" level="ERROR"/>
<logger name="org.ehcache" level="WARN"/>
<logger name="org.apache" level="WARN"/>
<logger name="org.apache.catalina.startup.DigesterFactory" level="OFF"/>
<logger name="org.bson" level="WARN"/>
<logger name="org.hibernate.validator" level="WARN"/>
<logger name="org.hibernate" level="WARN"/>
<logger name="org.hibernate.ejb.HibernatePersistence" level="OFF"/>
<logger name="org.springframework" level="WARN"/>
<logger name="org.springframework.web" level="WARN"/>
<logger name="org.springframework.security" level="WARN"/>
<logger name="org.springframework.cache" level="WARN"/>
<logger name="org.thymeleaf" level="WARN"/>
<logger name="org.xnio" level="WARN"/>
<logger name="springfox" level="WARN"/>
<logger name="sun.rmi" level="WARN"/>
<logger name="liquibase" level="WARN"/>
<logger name="LiquibaseSchemaResolver" level="INFO"/>
<logger name="sun.rmi.transport" level="WARN"/>

<!-- https://logback.qos.ch/manual/configuration.html#shutdownHook and https://jira.qos.ch/browse/LOGBACK-1090 -->
<shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook"/>

<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>
</contextListener>

</configuration>

关于spring-boot - LOGBACK : No context given for c. q.l.core.rolling.SizeAndTimeBasedRollingPolicy@1162810564,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59480632/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com