change execution listener


I’m looking for something to solve the following: We use liquibase to manage initial values for our application. Now when upgrading a database we would like to generate a list of insert statements that have effectively been run against the database (that were not skipped due to preconditions or other conditions).

Is there a way for this using liquibase?

I was thinking of a listener that can be registered with Liquibase and that is notified on some points during changeset processing… would this then be a reasonable enhancement?

Thanks in advance!


There is the updateSQL mode, but that does not handle preconditions on changeSets. In 2.0, there is logLevel=DEBUG which will log the SQL ran, although you get a lot of other information that you are not interested in.

With the 2.0 extension system ( you can register a custom database class that overrides the execute() method (or a method similar to that) which will log the SQL as well. If you are only interested in the SQL for certain changes, you could register custom versions of them that output the SQL when executed.


Hi Nathan,

thank you for your fast reply and the hint. I think using a custom Database class sounds good, I will try this.

best regards,



I ran into a problem regarding DatabaseFactory class. The register method takes an object of type Database as argument. This and the last lines at made me think, that the same instance is reused:

Threading/Singleton notes

  • returnDatabase = foundDatabases.iterator().next().getClass().newInstance();
  • Maybe the same instance of Database cannot be reused because of some conflicting state. But why is regiser() not taking a Class<? extends Database>-object as argument? 

    My problem now is that I like to inject some listeners and services into my database from an IOC framework (hivemind/hiveapp). Thats why I’m registering an instance of my Database at liquibase.DatabaseFactory. But this does not work right now. 

    I would go and patch DatabaseFactory to return the same instance as registered, what do you think?

    Btw, I’m currently using liquibase 2.0.2-SNAPSHOT from tunk (r2067)



    I think it’s good to patch DatabaseFactory to return the same instance. The reason register takes an object not the class is because we do use instances of the database classes to check for whether it should respond to a given url. It would be fine to add another register() method that takes Class<? extends Database> as well for convencience