I have an encoder using net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder
to configure the log content via a mix of stock providers, patterns and custom providers. The same is to be used in different appenders, e.g. console, file, rolling file and a custom one for unit testing. I don't want to repeat the same configuration in every appender as it is exactly the same, so I wonder if there is a way to share it across different appenders?
e.g.
<configuration>
<appender name="FILE_LOG" class="ch.qos.logback.core.FileAppender">
<encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
... configuration can be shared ...
</encoder>
</appender>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
... repeated the exact same configuration ...
</encoder>
</appender>
I know there is this "include" feature, but it seems it has to start from the root level (i.e. appender
) for inclusion. Is there a way to "include" at the encoder
level?