在我的工作中,我们开始使用flyway,数据库管理员向我询问飞路是否有日志。在阅读了一些关于互联网和飞路文档的文章之后,我没有找到办法进行这种配置。
在StackOverflow上,有些用户说只需要将log4j放在类路径上就可以了。我试过把log4j文件但对我不起作用,但是当我尝试将SLF4J的文件放在flyway(classpath)的lib目录上时:
flyway的输出更改了插入日志记录前缀:
C:\ dev \ flyway-4.0.3> flyway -configFile = C:/ dev / repos \ flyway / ad / DT / flyway.conf / flyway.conf info -q [主要] INFO org.flywaydb.core.internal.util.VersionPrinter - Boxfuse的Flyway 4.0.3 [主要] INFO org.flywaydb.commandline.Main - [main] INFO org.flywaydb.core.internal.dbsupport.DbSupportFactory - 数据库:jdbc:sqlserver:// xxxxxxxxxx \ sql2008:1437; authentication = NotSpecified; authenticationScheme = nativeAuthentication; xopenStat ES = FALSE; sendTimeAsDatetime = TRUE; trustServerCertificate = FALSE; TransparentNetworkIPResolution = TRUE; serverNameAsACE = FALSE; sendStringParametersAsUnicode = TRUE; selectMethod =直接; responseBuffering =自适应的 Ë; PACKETSIZE = 8000; multiSubnetFailover = FALSE; loginTimeout = 15; LOCKTIMEOUT = -1; lastUpdateCount = TRUE;加密= FALSE; disableStatementPooling = TRUE;的databaseName = TST_FLYWAY; columnEncryptionSetting =禁用;申请 icationName =用于SQL Server的Microsoft JDBC驱动程序; applicationIntent = readwrite; (Microsoft SQL Server 10.50) [main] INFO org.flywaydb.core.internal.dbsupport.sqlserver.SQLServerDbSupport - SQLServer不支持为当前会话设置架构。默认架构未更改为[flyway] [主要] INFO org.flywaydb.commandline.Main -
但是我在 simplelogger.properties 文件上配置的目录上没有创建文件:
org.slf4j.simpleLogger.logFile = C:/dev/flyway-4.0.3/log/flyway.log
我应该怎么做才能配置日志?
欢迎任何帮助。
答案 0 :(得分:1)
使用slf4j和logback 在哪里添加文件(你也可以使用simplelogger,但更好的是logback)
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>
修改flyway.cmd
%JAVA_CMD% -cp "%INSTALLDIR%\conf;%INSTALLDIR%\lib\*;%INSTALLDIR%\drivers\*" org.flywaydb.commandline.Main %*