开发者

Sharing one encoder/pattern among multiple Appenders in Logback

This is my first foray i开发者_如何转开发nto 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?


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>


For anyone interested I did find this little jewel from Chapter 4 of LogBack's documentation: "Each layout/encoder is associated with one and only one appender, referred to as the owning appender." which to me reads as though it's not possible for Appenders to share a single Encoder instance.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜