I am trying add custom field into logstash appender in logback-spring.xml like that:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="stash" class="net.logstash.logback.appender.LogstashSocketAppender">
<host>xx.xx.xx.xx</host>
<port>xxxxx</port>
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<includeMdcKeyName>myField</includeMdcKeyName>
</encoder>
</appender>
<root level="info">
<appender-ref ref="stash" />
</root>
</configuration>
It gives me error:
Exception in thread "main" java.lang.IllegalStateException: Logback configuration error detected: ERROR in ch.qos.logback.core.joran.spi.Interpreter@34:71 - no applicable action for [encoder], current ElementPath is [[configuration][appender][encoder]]
When I tried console appender and I tried print that field like in sample below it worked.
<layout>
<Pattern>%-4r [%thread] %-5level My Field: [%X{myField:--}] %msg%n</Pattern>
</layout>
Can you tell me what I did wrong with udp appender? Thank you in advice.