我可以使用lombok @ Slf4j指定log4j类别吗?

时间:2018-12-21 07:16:29

标签: log4j lombok

我知道在获取这样的记录器时log4j可以使用类别

org.apache.log4j.Logger.getLogger("category1").warn("debug msg for stdout1 appender");
org.apache.log4j.Logger.getLogger("category2").info("info msg for stdout2 appender");

log4j.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

    <appender name="stdout1" class="org.apache.log4j.ConsoleAppender">
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="[%.4t] %-5p %c{1} - %m%n" />
        </layout>
    </appender>

    <appender name="stdout2" class="org.apache.log4j.ConsoleAppender">
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d [%.4t] %-5p %c{1} - %m%n" />
        </layout>
    </appender>

    <category name="category1">
        <priority value="INFO" />
        <appender-ref ref="stdout1" />
    </category>

    <category name="category2">
        <priority value="DEBUG" />
        <appender-ref ref="stdout2" />
    </category>

</log4j:configuration>

我想知道如何使用lombok @ Slf4j。

代码取自this post

0 个答案:

没有答案