Reputation: 55
Here on my job we started the use of flyway and the databases admins asked to me if the flyway has a log. After read some articles on internet and on documentation of the flyway, I did not find a way to do this configuration.
Here on StackOverflow some users say that only is necessary put the log4j on classpath and it should work. I tried put log4j files but does not work for me, however when I tried put the files of SLF4J on lib directory of flyway (classpath):
The output of flyway has changed inserting logging prefixes:
C:\dev\flyway-4.0.3>flyway -configFile=C:/dev/repos\flyway/ad/DT/flyway.conf/flyway.conf info -q [main] INFO org.flywaydb.core.internal.util.VersionPrinter - Flyway 4.0.3 by Boxfuse [main] INFO org.flywaydb.commandline.Main - [main] INFO org.flywaydb.core.internal.dbsupport.DbSupportFactory - Database: jdbc:sqlserver://xxxxxxxxxx\sql2008:1437;authentication=NotSpecified;authenticationScheme=nativeAuthentication;xopenStat es=false;sendTimeAsDatetime=true;trustServerCertificate=false;TransparentNetworkIPResolution=true;serverNameAsACE=false;sendStringParametersAsUnicode=true;selectMethod=direct;responseBuffering=adaptiv e;packetSize=8000;multiSubnetFailover=false;loginTimeout=15;lockTimeout=-1;lastUpdateCount=true;encrypt=false;disableStatementPooling=true;databaseName=TST_FLYWAY;columnEncryptionSetting=Disabled;appl icationName=Microsoft JDBC Driver for SQL Server;applicationIntent=readwrite; (Microsoft SQL Server 10.50) [main] INFO org.flywaydb.core.internal.dbsupport.sqlserver.SQLServerDbSupport - SQLServer does not support setting the schema for the current session. Default schema NOT changed to [flyway] [main] INFO org.flywaydb.commandline.Main -
But no file was created on the directory that I configured on simplelogger.properties file:
org.slf4j.simpleLogger.logFile=C:/dev/flyway-4.0.3/log/flyway.log
What I should do to configure the log?
Any help will be welcome.
Upvotes: 2
Views: 4927
Reputation: 8386
Using slf4j and logback where to add the file (you can use simplelogger also but logback is better)
C: \ flyway - 4.0.3
├─ conf
│ logback.xml
└ ─ lib
Logback-classic-1.1.7.jar
Logback-core-1.1.7.jar
Slf4j-api-1.7.21.jar
Logback.xml
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<property scope="context" name="LOG_DIR" value="logs" />
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %p : %m%n</pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_DIR}/flyway.log</file>
<append>true</append>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOG_DIR}/flyway.%d{yyyy-MM-dd}.log</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %p : %m%n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>
</configuration>
Modify flyway.cmd
%JAVA_CMD% -cp "%INSTALLDIR%\conf;%INSTALLDIR%\lib\*;%INSTALLDIR%\drivers\*" org.flywaydb.commandline.Main %*
Upvotes: 1