Logback: there is no applicable action for [encoder], the current ElementPath is [[configuration] [appender] [encoder]]

I wrote a logging application and saved the logs in ElasticSearch, then add this appender to the logback.xml file. I applied it in one application and I got the logs from ES.

But when I apply it to another application, the following error appears in the error log:

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:

 ... <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 any action (or how to add it) for the log?

+7
java logging logback
source share
1 answer

This is probably due to your custom application.

 extends AppenderBase<ILoggingEvent> 

This AppenderBase does not implement the encoder / template inside it, but if you look at the console appender, it extends the one that has them as objects.

Thus, it cannot display the encoder / patterns on your object.

Just remove them from the all togeher app.

 ... <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, you will need to modify the Appender class to implement them.

+2
source share

All Articles