Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharing one encoder/pattern among multiple Appenders in Logback

This is my first foray into the world of LogBack, however I couldn't find anywhere in the documentation where I could define an encoder/pattern once and share it among multiple appenders. Any idea how to accomplish this?

like image 982
Will Madison Avatar asked Apr 25 '11 14:04

Will Madison


1 Answers

Patterns are reusable with variable substitution.

<configuration>      <property name="defaultPattern"         value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n" />      <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">         <encoder>             <pattern>${defaultPattern}</pattern>         </encoder>     </appender>      <root level="debug">         <appender-ref ref="STDOUT" />     </root> </configuration> 
like image 130
palacsint Avatar answered Sep 30 '22 19:09

palacsint