logback-classic 版本 1.2.9 中的 ContextInitializer 不支持 Groovy 配置文件

Ole*_* K. 4 groovy spring-boot

更新到 spring-boot-starter-parent 2.6.2,我的应用程序由于以下错误而无法启动

Unexpected filename extension of file [file:logback.groovy]. Should be either .groovy or .xml。查看上述类的源代码,发现以下内容:

        final String urlString = url.toString();
        if (urlString.endsWith("xml")) {
            JoranConfigurator configurator = new JoranConfigurator();
            configurator.setContext(loggerContext);
            configurator.doConfigure(url);
        } else {
            throw new LogbackException("Unexpected filename extension of file [" + url.toString() + "]. Should be either .groovy or .xml");
        }
Run Code Online (Sandbox Code Playgroud)

那么看起来在最新版本中他们刚刚删除了 groovy 支持?除了回到Excel配置之外还有什么解决办法吗?谢谢

And*_*son 8

没有解决方法。出于安全原因,Groovy 支持在 1.2.9 中被删除。从发布公告来看:

删除了 Groovy 配置支持。由于日志记录如此普遍,并且 Groovy 的配置可能过于强大,因此出于安全原因不太可能恢复此功能。

此删除以及其他一些更改是为了响应CVE-2021-42550而完成的。