Java SDK 1.8.0_131
Liquibase 3.5.3
eclipse IDE Neon 3 (eclipse 4.6.3)
I am trying to replace the logger as outlined in Fixing liquibase logging (in Spring) with SLF4J and Log4J but so far I haven't been successful.
The reason seems to be because ServiceLocator.instance(), called from LogFactory.getLog(), returns a null, and the defaultLogger is returned instead.
Is there some obvious initialization code that may I have missed? (I have used examples found by googling, combined with trial and error).
I first tried replacing the logger by adding a maven dependency to Matt Bertolinis liquibase-slf4j, but that didn't have any effect.
I then tried replacing the logger as simply as possible:
- Created a package liquibase.ext.logging in the project where I'm calling Liquibase from
- Created a class "public class UkelonnLiquibaseLogger extends AbstractLogger" in this package
But the liquibase output continued to be written to the console, so the class wasn't picked up.
When I debugged into the startup code I was able to hit code in the ServiceLocator constructor, called from the static initializer of the ServiceLocator class. Eclipse didn't let me set any breakpoints inside the static initializer of ServiceLocator so I wasn't able to see what was going on there. I wasn't able to figure out if any exceptions were thrown from the constructor either.
However when I next hit the breakpoints in ServiceLocator.getInstance() the instance was null.
I had a breakpoint in ServiceLocator.setInstance() as well, but this breakpoint was never called.
This is how I create and use Liquibase:
- public void createSchema(PooledConnection connect) throws SQLException, LiquibaseException {
- DatabaseConnection databaseConnection = new JdbcConnection(connect.getConnection());
- ClassLoaderResourceAccessor classLoaderResourceAccessor = new ClassLoaderResourceAccessor(getClass().getClassLoader());
- Liquibase liquibase = new Liquibase("db-changelog/db-changelog.xml", classLoaderResourceAccessor, databaseConnection);
- liquibase.update("");
- }
- Steinar