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.
But when I apply it into another application, logback shows the following error:
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:
...
<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?
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.
Thus it cannot map the encoder/patterns onto your object.
Just remove them from the appender all togeher.
...
<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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With