I would like to change the Logger outpout

Hi,

I’m using Liquibase API with a Java application and for methods like “update”, “rollback”, etc. I would like to get the entire log data (every Info, Debug, Warning and Severe data) into a file.

Currently, by default, Logger’s output is the standard one (I guess) but how can I change it, if it’s possible.

Thanks for your time.

Hi! May I ask which version of Liquibase you are using? Also, are you embedding Liquibase into an existing application or are you running it by other means (command line, Maven, Ant, etc)?

Hi,
I’m using 3.8.9 version.
Actually, I made a java server which allows me to run liquibase commands (as “update”, “updateSQL”, etc…). Those commands are ran by the java class “Liquibase” (https://www.liquibase.org/javadoc/liquibase/Liquibase.html) ; so I run Liquibase commands by the object methods into my own application.
And this object is ‘associated’ to an other one, “Logger” (https://www.liquibase.org/javadoc/liquibase/logging/Logger.html), which prints all logging informations on the standard output (I suppose).
I hope I was clearer, tell me if not.

Based on my research, version 3.8.9 uses SLF4J as its default logging framework. It also seems to pull in logback-classic as the SLF4J implementation. By default, SLF4J and logback-classic log to standard out. If you want to change how the logging works you have a few options:

  1. Create a logback.xml file in your classpath and change the appenders for the logback loggers to go to a file. You can get more information on Logback at their web site. http://logback.qos.ch/
  2. Stop using Logback and add one of SLF4J’s bridge jars to route the SLF4J’s log output to the logging framework of your choice. http://www.slf4j.org/legacy.html
  3. Create your own logger by implementing the Logger and LoggerFactory interfaces.

There may be other options but that’s what I was able to gather reading the 3.8.x code. I think I would go with option 1 but I generally choose SLF4J and Logback myself when I write programs.

Hope this helps. Let me know if you have additional questions.