Class LogFactory


  • public class LogFactory
    extends java.lang.Object
    Factory for loggers. Custom MigrationResolver, MigrationExecutor, Callback and JavaMigration implementations should use this to obtain a logger that will work with any logging framework across all environments (API, Maven, Gradle, CLI, etc).
    • Method Summary

      Modifier and Type Method Description
      static Log getLog​(java.lang.Class<?> clazz)
      Retrieves the matching logger for this class.
      static void setFallbackLogCreator​(LogCreator fallbackLogCreator)
      Sets the fallback LogCreator.
      static void setLogCreator​(LogCreator logCreator)
      Sets the LogCreator that will be used.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • setLogCreator

        public static void setLogCreator​(LogCreator logCreator)
        Sets the LogCreator that will be used. This will effectively override Flyway's default LogCreator auto-detection logic and force Flyway to always use this LogCreator regardless of which log libraries are present on the classpath.

        This is primarily meant for integrating Flyway into environments with their own logging system (like Ant, Gradle, Maven, ...). This ensures Flyway is a good citizen in those environments and sends its logs through the expected pipeline.

        Parameters:
        logCreator - The factory for implementation-specific loggers.
      • setFallbackLogCreator

        public static void setFallbackLogCreator​(LogCreator fallbackLogCreator)
        Sets the fallback LogCreator. This LogCreator will be used as a fallback solution when the default LogCreator auto-detection logic fails to detect a suitable LogCreator based on the log libraries present on the classpath.
        Parameters:
        fallbackLogCreator - The factory for implementation-specific loggers to be used as a fallback when no other suitable loggers were found.
      • getLog

        public static Log getLog​(java.lang.Class<?> clazz)
        Retrieves the matching logger for this class.
        Parameters:
        clazz - The class to get the logger for.
        Returns:
        The logger.