I am converting my logback.xml file to groovy and am posed with this challenge of adding appenders to my custom appender!
Currently I do it like this:
<appender name="MyCustomAppender" class="url.MyCustomAppender">
<param name="BufferSize" value="10000"/>
<param name="Blocking" value="true"/>
<appender-ref ref="FILE"/>
<!-- <appender-ref ref="CONSOLE"/> -->
<appender-ref ref="CONSOLE_ERR"/>
</appender>
I tried something like this with groovy but it fails:
appender("MyCustomAppender", MyCustomAppender) {
BufferSize = 10000
Blocking = true
appender-ref('ref':"CONSOLE_ERR");
appender-ref('ref':"FILE");
}
I can’t change the custom appender as it is in shared code, so that isn’t a solution. I would just like to do the exact same thing that happens in xml, but in groovy.
Try this:
I suppose your
MyCustomAppenderimplements the AppenderAttachable interface (or at least has apublic void addAppender(Appender<E> newAppender)method).