I created a custom layout (as shown in Chapter 6: Layouts, http://logback.qos.ch/manual/layouts.html), so do I have to patch logback, or there is a configurable way to let logback knows about my custom layout class?
Thank you.
I created a custom layout (as shown in Chapter 6: Layouts, http://logback.qos.ch/manual/layouts.html), so do I have to patch logback, or there is a configurable way to let logback knows about my custom layout class?
Thank you.
您可以使用自定义布局的完整命名空间在 logback.xml 中引用您的布局。因此,如果您的布局com.mydomain.logback.layouts.MyCustomLayout
位于您的 logback.xml 中,那么您将有一个看起来像这样的 appender 定义:
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="com.mydomain.logback.layouts.MyCustomLayout" />
</appender>
现在,每次通过 STDOUT appender 传递日志事件时,它都会由您的自定义 appender 处理。无需重新编译 Logback。