Flyway logging with log4j?

2019-02-24 01:55发布

hy guys,

is there a best practice of how to get flyway output into log4j logs?

I'm currently running with following 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>

I have already searched for an answer online but could not figure it out.

标签: flyway
1条回答
beautiful°
2楼-- · 2019-02-24 02:24

Flyway will automatically use Log4J if it is available on the classpath.

查看更多
登录 后发表回答