gpt4 book ai didi

slf4j - logback slf4j 无法在日志文件中获取日志语句

转载 作者:行者123 更新时间:2023-12-04 20:51:53 25 4
gpt4 key购买 nike

登录文件

<?xml version="1.0" encoding="UTF-8"?>

-->
<configuration>
<!-- Errors were reported during translation. -->
<!-- No root logger configuration was found -->

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>


<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>c:\log\test.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%msg%n</pattern>
</encoder>
</appender>

<logger name="com.base22" level="DEBUG" />
<root level="debug">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
</configuration>

pom.xml 依赖
 <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>


<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.6.1</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>0.9.26</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>0.9.26</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-access</artifactId>
<version>0.9.26</version>
</dependency>

将上述配置用于 logback.....log 语句显示在控制台上,但未创建 test.log,并且在创建文件后我什至在文件中也找不到任何日志..我是否需要编写任何其他配置

最佳答案

您的 logback.xml 未放置在 logback 查找它的位置,因此它会默默地回退到“打印到控制台”配置。

http://logback.qos.ch/manual/configuration.html有关配置机制的所有详细信息。

关于slf4j - logback slf4j 无法在日志文件中获取日志语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9707182/

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