使用log4j进行飞路记录?

hy伙伴,

是否有如何将flyway输出到log4j日志的最佳实践?

我目前正在运行以下log4j.xml:

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

<log4j:configuration>
    <appender name="CA" class="org.apache.log4j.ConsoleAppender">
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%-p - %m%n"/>
        </layout>
        <filter class="org.apache.log4j.varia.LevelRangeFilter">
            <param name="levelMin" value="INFO"/>
            <param name="levelMax" value="ERROR"/>
        </filter>
    </appender>

    <appender name="fileAppender" class="org.apache.log4j.RollingFileAppender">
        <param name="append" value="false"/>
        <param name="file" value="log.out"/>
        <param name="immediateFlush" value="true"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
        </layout>
    </appender>

    <logger name="com.googlecode.flyway.core.migration" additivity="false">
        <level value="DEBUG"/> 
        <appender-ref ref="fileAppender"/>
    </logger>

    <root>
        <priority value="all"/>
        <appender-ref ref="CA"/>
        <appender-ref ref="fileAppender"/>
    </root>
</log4j:configuration>

我已经在网上搜索了一个答案,但无法弄明白.

最佳答案 如果类路径上有可用的话,它将自动使用Log4J.

点赞