java logback: [encoder] 没有适用的操作,当前 ElementPath 是 [[configuration][appender][encoder]]
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37022672/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
logback: no applicable action for [encoder], current ElementPath is [[configuration][appender][encoder]]
提问by auntyellow
I wrote an Appender for logback and save logs into ElasticSearch then add this appender to logback.xml . I applied it into one application and I got logs from ES.
我为 logback 编写了一个 Appender 并将日志保存到 ElasticSearch 中,然后将此 appender 添加到 logback.xml 。我将它应用到一个应用程序中,并从 ES 获得了日志。
But when I apply it into another application, logback shows the following error:
但是当我将它应用到另一个应用程序时,logback 显示以下错误:
16:18:26,040 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [com.dcf.iqunxing.fx.dashcam.agent.log.appender.logback.DashcamAppender]
16:18:26,062 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [dashcamAppender]
16:18:26,078 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@110:12 - no applicable action for [encoder], current ElementPath is [[configuration][appender][encoder]]
16:18:26,080 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@111:13 - no applicable action for [Pattern], current ElementPath is [[configuration][appender][encoder][Pattern]]
My logback.xml is:
我的 logback.xml 是:
...
<appender name="dashcamAppender"
class="com.dcf.iqunxing.fx.dashcam.agent.log.appender.logback.DashcamAppender">
<encoder>
<Pattern>.%d{HH:mm:ss.SSS} [%thread] %-5level %logger{35} - %msg %n</Pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>TRACE</level>
</filter>
</appender>
...
Lost some action (or how to add them) for logback?
为 logback 丢失了一些操作(或如何添加它们)?
回答by VeenarM
It's likely due to your custom appender.
这可能是由于您的自定义附加程序。
extends AppenderBase<ILoggingEvent>
This AppenderBase doesn't implement the encoder/pattern inside it - but if you look at the console appender it extends one that does have them as objects.
这个 AppenderBase 并没有在其中实现编码器/模式 - 但是如果您查看控制台 appender,它会扩展一个确实将它们作为对象的附加器。
Thus it cannot map the encoder/patterns onto your object.
因此它无法将编码器/模式映射到您的对象上。
Just remove them from the appender all togeher.
只需将它们从 appender 中删除即可。
...
<appender name="dashcamAppender" class="com.dcf.iqunxing.fx.dashcam.agent.log.appender.logback.DashcamAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>TRACE</level>
</filter>
</appender>
...
If you want to use them, then you'd need to change your Appender class to implement them.
如果你想使用它们,那么你需要改变你的 Appender 类来实现它们。