如何在logback.groovy中包含xml配置
发布时间:2020-12-14 16:23:41 所属栏目:大数据 来源:网络整理
导读:我正在编写一个 Spring Boot应用程序,需要使用Groovy灵活地控制我的logback配置.在Spring Boot中,我所要做的就是创建src / main / resources / logback.groovy,它会自动用于配置. 我想做的是从Spring Boot的默认logback配置开始,只需根据需要覆盖或修改设置.
我正在编写一个
Spring Boot应用程序,需要使用Groovy灵活地控制我的logback配置.在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> 是否有类似于上面的include行,我可以在logback.groovy中使用?我可以查看base.xml的内容和它的其他包含文件,看看如何手动复制它,但它会添加一些我想避免的样板代码. 感谢您的任何帮助,您可以提供. 解决方法
有一个在线
tool,它将给定的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) 说到< include>对于常规配置,这是not supported. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |