gpt4 book ai didi

java - 使用 Spring-Boot 的 Logback 配置实时重新加载 (scan=true)

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:20:09 29 4
gpt4 key购买 nike

好的,我正在尝试配置一个 logback-spring.xml

我的目标是在修改后自动重新加载配置文件。

这就是 doc 的内容说:

来自:

<configuration>
...
</configuration>

收件人:

<configuration scan="true" scanPeriod="30 seconds">
...
</configuration>

毫无疑问,如果我不使用任何元素:

<springProperty>

<springProfile>

实时重新加载没有问题。另外,如果我不使用 scan="true"springProfilespringProperty 也能正常工作。

所以我的结论是 spring 元素和 scan 不喜欢彼此。我收到以下类型的错误:

16:29:39,101 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@12:125 - no applicable action for [springProperty], current ElementPath  is [[configuration][springProperty]]
16:29:39,102 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@16:109 - no applicable action for [springProperty], current ElementPath is [[configuration][springProperty]]
16:29:39,102 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@19:64 - no applicable action for [springProperty], current ElementPath is [[configuration][springProperty]]
16:29:39,103 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@33:29 - no applicable action for [springProfile], current ElementPath is [[configuration][springProfile]]
16:29:39,103 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@34:70 - no applicable action for [appender], current ElementPath is [[configuration][springProfile][appender]]
16:29:39,103 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@35:13 - no applicable action for [encoder], current ElementPath is [[configuration][springProfile][appender][encoder]]
16:29:39,103 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@36:14 - no applicable action for [pattern], current ElementPath is [[configuration][springProfile][appender][encoder][pattern]]
16:29:39,104 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@38:12 - no applicable action for [append], current ElementPath is [[configuration][springProfile][appender][append]]
16:29:39,104 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@39:10 - no applicable action for [file], current ElementPath is [[configuration][springProfile][appender][file]]
16:29:39,104 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@42:70 - no applicable action for [appender], current ElementPath is [[configuration][springProfile][appender]]
16:29:39,104 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@43:13 - no applicable action for [encoder], current ElementPath is [[configuration][springProfile][appender][encoder]]
16:29:39,104 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@44:14 - no applicable action for [pattern], current ElementPath is [[configuration][springProfile][appender][encoder][pattern]]
16:29:39,105 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@46:12 - no applicable action for [append], current ElementPath is [[configuration][springProfile][appender][append]]
16:29:39,105 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@47:10 - no applicable action for [file], current ElementPath is [[configuration][springProfile][appender][file]]
16:29:39,105 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@50:70 - no applicable action for [appender], current ElementPath is [[configuration][springProfile][appender]]
16:29:39,105 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@51:13 - no applicable action for [encoder], current ElementPath is [[configuration][springProfile][appender][encoder]]
16:29:39,106 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@52:14 - no applicable action for [pattern], current ElementPath is [[configuration][springProfile][appender][encoder][pattern]]
16:29:39,106 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@54:12 - no applicable action for [append], current ElementPath is [[configuration][springProfile][appender][append]]
16:29:39,106 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@55:10 - no applicable action for [file], current ElementPath is [[configuration][springProfile][appender][file]]
16:29:39,106 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@58:70 - no applicable action for [appender], current ElementPath is [[configuration][springProfile][appender]]
16:29:39,106 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@59:13 - no applicable action for [encoder], current ElementPath is [[configuration][springProfile][appender][encoder]]
16:29:39,107 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@60:14 - no applicable action for [pattern], current ElementPath is [[configuration][springProfile][appender][encoder][pattern]]
16:29:39,107 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@62:12 - no applicable action for [append], current ElementPath is [[configuration][springProfile][appender][append]]
16:29:39,107 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@63:10 - no applicable action for [file], current ElementPath is [[configuration][springProfile][appender][file]]
16:29:39,107 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@66:70 - no applicable action for [appender], current ElementPath is [[configuration][springProfile][appender]]
16:29:39,107 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@67:13 - no applicable action for [encoder], current ElementPath is [[configuration][springProfile][appender][encoder]]
16:29:39,107 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@68:14 - no applicable action for [pattern], current ElementPath is [[configuration][springProfile][appender][encoder][pattern]]
16:29:39,108 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@70:12 - no applicable action for [append], current ElementPath is [[configuration][springProfile][appender][append]]
16:29:39,108 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@71:10 - no applicable action for [file], current ElementPath is [[configuration][springProfile][appender][file]]
16:29:39,108 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@74:53 - no applicable action for [logger], current ElementPath is [[configuration][springProfile][logger]]
16:29:39,108 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@75:35 - no applicable action for [appender-ref], current ElementPath is [[configuration][springProfile][logger][appender-ref]]
16:29:39,108 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@78:54 - no applicable action for [logger], current ElementPath is [[configuration][springProfile][logger]]
16:29:39,108 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@79:35 - no applicable action for [appender-ref], current ElementPath is [[configuration][springProfile][logger][appender-ref]]
16:29:39,108 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@84:23 - no applicable action for [logger], current ElementPath is [[configuration][springProfile][logger]]
16:29:39,108 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@85:35 - no applicable action for [appender-ref], current ElementPath is [[configuration][springProfile][logger][appender-ref]]
16:29:39,109 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@91:37 - no applicable action for [logger], current ElementPath is [[configuration][springProfile][logger]]
16:29:39,109 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@92:35 - no applicable action for [appender-ref], current ElementPath is [[configuration][springProfile][logger][appender-ref]]
16:29:39,109 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@95:54 - no applicable action for [logger], current ElementPath is [[configuration][springProfile][logger]]
16:29:39,109 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@96:35 - no applicable action for [appender-ref], current ElementPath is [[configuration][springProfile][logger][appender-ref]]
16:29:39,109 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@99:54 - no applicable action for [logger], current ElementPath is [[configuration][springProfile][logger]]
16:29:39,109 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@100:35 - no applicable action for [appender-ref], current ElementPath is [[configuration][springProfile][logger][appender-ref]]
16:29:39,109 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@103:23 - no applicable action for [root], current ElementPath is [[configuration][springProfile][root]]
16:29:39,109 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@104:35 - no applicable action for [appender-ref], current ElementPath is [[configuration][springProfile][root][appender-ref]]
16:29:39,109 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@109:28 - no applicable action for [springProfile], current ElementPath is [[configuration][springProfile]]
16:29:39,110 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@110:72 - no applicable action for [appender], current ElementPath is [[configuration][springProfile][appender]]
16:29:39,110 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@111:13 - no applicable action for [encoder], current ElementPath is [[configuration][springProfile][appender][encoder]]
16:29:39,110 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@112:14 - no applicable action for [pattern], current ElementPath is [[configuration][springProfile][appender][encoder][pattern]]
16:29:39,110 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@113:14 - no applicable action for [charset], current ElementPath is [[configuration][springProfile][appender][encoder][charset]]
16:29:39,110 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@117:76 - no applicable action for [appender], current ElementPath is [[configuration][springProfile][appender]]
16:29:39,110 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@118:13 - no applicable action for [encoder], current ElementPath is [[configuration][springProfile][appender][encoder]]
16:29:39,110 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@119:14 - no applicable action for [pattern], current ElementPath is [[configuration][springProfile][appender][encoder][pattern]]
16:29:39,110 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@120:14 - no applicable action for [charset], current ElementPath is [[configuration][springProfile][appender][encoder][charset]]
16:29:39,110 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@124:54 - no applicable action for [logger], current ElementPath is [[configuration][springProfile][logger]]
16:29:39,110 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@125:38 - no applicable action for [appender-ref], current ElementPath is [[configuration][springProfile][logger][appender-ref]]
16:29:39,111 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@128:23 - no applicable action for [root], current ElementPath is [[configuration][springProfile][root]]
16:29:39,111 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@129:34 - no applicable action for [appender-ref], current ElementPath is [[configuration][springProfile][root][appender-ref]]

所以正如我已经说过的,如果我删除 scan=true,配置就会起作用。如果我删除 springProfiles 和 properties 并保留 scan=true ,配置将再次工作,但两者都有问题?

我认为这样做很可能是不可能的,但是有人找到了这样做的方法吗?

编辑:在我发布问题将近一周后,Spring 更新了他们的 documentation .我仍然在寻找答案,我认为可能有一种方法可以在 Spring 属性和 logback 配置文件之间使用属性文件的中间层,因为正如 logback 文档所说,您可以将属性文件导入到配置中。但即使如此,springProfile 的问题仍然存在。

最佳答案

Spring springProfile 和 springProperty 元素存在扫描问题。

可以在以下位置找到更多信息:

https://springframework.guru/using-logback-spring-boot/

问题记录在:

https://github.com/spring-projects/spring-boot/issues/7955

关于java - 使用 Spring-Boot 的 Logback 配置实时重新加载 (scan=true),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41594107/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com