在我的springboot3应用程序中,我在application.yml
中有一个属性:
log:
path:
info: logs/datahub-info`
我的logback-spring.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<springProperty scope="context" name="FILE_PATH_INFO" source="log.path.info" defaultValue="logs/app1-info"/>
<appender name="info-file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!--日志文件输出的文件名 -->
<File>${FILE_PATH_INFO}.log</File>
...everything else to config file log attributes...
</appender>
...everything else config...
</configuration>
当运行应用程序时,日志文件如预期的那样,但发生了这样的logkback warn
:
18:24:34,267 |-WARN in Logger[org.springframework.core.env.PropertySourcesPropertyResolver] - No appenders present in context [default] for logger [org.springframework.core.env.PropertySourcesPropertyResolver].
如何解决这个警告?
添加NopStatusListener
将删除logback中的所有内容,但无法解决此警告。
1条答案
按热度按时间b4wnujal1#
我在没有使用Spring来管理我的应用程序时得到了这个错误。我必须在resources文件夹中创建一个logback.xml,如下所示:
我需要
root
部分。可能有一种方法可以将appender分配给任何试图进行日志记录的类,而不依赖于根节。