如何在logback.groovy中包含xml配置

bal*_*cle 5 groovy logback spring-boot

我正在编写一个Spring Boot应用程序,需要使用Groovy控制我的登录配置的灵活性。在Spring Boot中,我要做的就是创建src / main / resources / logback.groovy,它会自动用于配置。

我想做的是从Spring Boot的默认logback配置开始,然后根据需要覆盖或修改设置。

如果我使用的是logback.xml而不是logback.groovy,则可以执行以下操作。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <include resource="org/springframework/boot/logging/logback/base.xml"/>
    <logger name="org.springframework.web" level="DEBUG"/>
</configuration>
Run Code Online (Sandbox Code Playgroud)

是否可以在logback.groovy中使用与上面的包含行类似的内容?我可以查看base.xml及其它包含的其他文件的内容,以了解如何手动复制此文件,但是它会添加一些我想避免的样板代码。

感谢您的任何帮助,您可以提供。

Opa*_*pal 5

有一个在线工具可以将给定logback.xml文件转换为等效文件logback.groovy。在您的情况下,它导致:

//
// Built on Thu Jul 16 09:35:34 CEST 2015 by logback-translator
// For more information on configuration files in Groovy
// please see http://logback.qos.ch/manual/groovy.html

// For assistance related to this tool or configuration files
// in general, please contact the logback user mailing list at
//    http://qos.ch/mailman/listinfo/logback-user

// For professional support please see
//   http://www.qos.ch/shop/products/professionalSupport

import static ch.qos.logback.classic.Level.DEBUG

logger("org.springframework.web", DEBUG)
Run Code Online (Sandbox Code Playgroud)

涉及到常规配置时不支持<include>它。