java - springboot logback:java.lang.ClassNotFoundException:org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout
问题描述
我使用 springboot(版本:2.1.5.RELEASE)创建项目,然后使用 logback-spring.xml 记录日志。
像这样的配置:
<appender name="FILE_ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/${appName}/${appName}-error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOG_PATH}/${appName}/${appName}-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>200MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<append>true</append>
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
</layout>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>error</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
但是当我启动我的应用程序时,logback 显示以下错误:
Exception in thread "main" java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Could not create component [layout] of type [org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout] java.lang.ClassNotFoundException: org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout
ERROR in ch.qos.logback.core.joran.spi.Interpreter@20:26 - no applicable action for [pattern], current ElementPath is [[configuration][appender][encoder][layout][pattern]]
ERROR in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Could not create component [layout] of type [org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout] java.lang.ClassNotFoundException: org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout
为 logback 丢失了一些操作(或如何添加它们)?
解决方案
要使用TraceIdPatternLogbackLayout
fromapm-toolkit-logback-1.x
你必须依赖工具包
行家:
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>apm-toolkit-logback-1.x</artifactId>
<version>8.1.0</version>
</dependency>
毕业典礼
compile group: 'org.apache.skywalking', name: 'apm-toolkit-logback-1.x', version: '8.1.0'
推荐阅读
- android - Android Oreo及以上版本将应用程序变成系统应用程序的正确方法是什么?
- node.js - npm install -g react-native-cli
- java - 实现游戏记分牌 API 的最佳数据结构
- python - 如何在python中将普通时间戳转换为纪元时间戳
- java - 在java中使用收集器进行分组操作后的转换
- c++ - 计算现金返还结果为 0
- css - 使用电话宽度和保持纵横比创建项目的响应式 Flex 布局
- swiftui - 包含多个变量的 SwiftUI 变量
- java - Eclipse 中的 Swing 窗口构建器在构造函数中定义变量
- amazon - 通过 Amazon API 查找我自己的产品评级