相关疑难解决方法(0)

使用多个配置文件配置回溯

我试图通过springboot下的配置文件拆分我的logback.xml,这是我的方法:

的logback-prod.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:- ${java.io.tmpdir:-/tmp}}/}spring.log}"/>
<include resource="org/springframework/boot/logging/logback/file- appender.xml" />

<root level="INFO">
    <appender-ref ref="CONSOLE" />
</root>
</configuration> 
Run Code Online (Sandbox Code Playgroud)

的logback-dev.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />

<root level="DEBUG">
    <appender-ref ref="CONSOLE" />
</root>
Run Code Online (Sandbox Code Playgroud)

logback.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="logback-${spring.profiles.active}.xml"/>

<root level="INFO">
    <appender-ref ref="FILE" />
    <appender-ref ref="CONSOLE" />
</root>
Run Code Online (Sandbox Code Playgroud)

最后使用:

-Dspring.profiles.active=dev
 or
-Dspring.profiles.active=prod
Run Code Online (Sandbox Code Playgroud)

我进入了控制台:

13:01:44,673 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@2:16 - no  applicable action for [configuration], current ElementPath  is [[configuration][configuration]]
13:01:44,674 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@3:81 …
Run Code Online (Sandbox Code Playgroud)

logback spring-boot

34
推荐指数
3
解决办法
4万
查看次数

标签 统计

logback ×1

spring-boot ×1