尝试将sentry(logback)集成到spring应用程序中,但遇到了此错误
java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.joran.spi.Interpreter@32:18 - no applicable action for [encoder], current ElementPath is [[configuration][appender][encoder]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@33:22 - no applicable action for [pattern], current ElementPath is [[configuration][appender][encoder][pattern]]logback.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"/> -->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] [%file:%line] - %msg %n</pattern>
</encoder>
</appender>
<appender name="Sentry" class="io.sentry.logback.SentryAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
<!-- Optionally add an encoder -->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%level] from %logger in %thread : %msg %n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="CONSOLE" />
</root>
<root level="ERROR">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="Sentry"/>
</root>
</configuration>我在这里做错了什么?
发布于 2021-05-25 15:57:53
不支持为SentryAppender配置编码器。所有的信息,如级别,记录器,线程等,都会以结构化的方式与日志消息一起发送到Sentry --不需要配置编码器。
在使用Sentry Spring Boot Starter时,可以自动配置SentryAppender,这样您就不需要将其添加到logback.xml (请参阅docs)
如果有我们遗漏的用例,并且您认为编码器应该是可配置的,请使用raise an issue。
https://stackoverflow.com/questions/67632061
复制相似问题