Liquibase logging with log4j2

Hello everyone,

I’ve recently had to upgrade from log4j to log4j2 due to some security concerns. With my new changes in place, I noticed that Liquibase log output is now only being logged to stdout, even though I have the log4j-liquibase jar plugin on my classpath, which should automatically pick up the Liquibase logs and redirect them.

I was scratching my head for a good few hours, until I had a look at the dependencies of the plugin and noticed it was using Liquibase 3.5.3 under the bonnet. I am currently using the latest version of Liquibase (4.3.1), so I temporarily downgraded to version 3.5.3, and sure enough the Liquibase logs started coming through via my configured loggers.

So my question is this: how do I best proceed with this? Do I just take the hit and downgrade Liquibase from version 4 to 3? I don’t use any extensions, and only use the core functionality, so this wouldn’t be a complete disaster (although I do hate downgrading libraries unless I really have to!). I know Liquibase uses its own custom logging so there are no external dependencies, but I assume that also means I am having to rely on these ‘magic’ plugins to redirect the output, and cannot do anything manually myself to redirect the logging from Liquibase. Please correct me if this is wrong.

Any help on this would be very much appreciated. I will pose a question on the Log4j2 Jira project, but I doubt they will upgrade their plugin jar to use Liquibase 4 just to appease me!

Many thanks,
Jon

@JonBetts this sounds like a bug. Would you mind logging in a ticket here?

Of course, if you definitely think there’s a chance it is a bug. I just wanted to put the question on here in case I was just being stupid. I’ll raise an issue on the Github page now. Thank you!

1 Like

Hi all, Gary Gregory here, I am one of the Apache Log4j developers. This issue is that Liquibase broke binary compatibility between versions 3.5.3 and 4.3.2 WITHOUT changing the package name and Maven coordinates. This is unfortunate. If I update the Log4j dependency 3.5.3 → 4.3.2 then the Log4j code no longer compiles, see below. There two types of solutions here:

  1. Release a version of Liquibase that restores compatibility
  2. Tell Log4j (me) how to update the code such that the next release provides support for Liquibase 4, which we would likely provide in a new module log4j-liquiabse4 which would be mutually exclusive to the existing log4j-liquiabse; we don’t want to blow up our existing users :wink:
|Description|Resource|Path|Location|Type|
|---|---|---|---|---|
|Implicit super constructor AbstractLogger() is undefined for default constructor. Must define an explicit constructor|Log4j2Logger.java|/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2|line 31|Java Problem|
|PRIORITY_DATABASE cannot be resolved to a variable|Log4j2Logger.java|/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2|line 49|Java Problem|
|The method buildMessage(String) is undefined for the type Log4j2Logger|Log4j2Logger.java|/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2|line 39|Java Problem|
|The method buildMessage(String) is undefined for the type Log4j2Logger|Log4j2Logger.java|/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2|line 44|Java Problem|
|The method buildMessage(String) is undefined for the type Log4j2Logger|Log4j2Logger.java|/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2|line 54|Java Problem|
|The method buildMessage(String) is undefined for the type Log4j2Logger|Log4j2Logger.java|/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2|line 59|Java Problem|
|The method buildMessage(String) is undefined for the type Log4j2Logger|Log4j2Logger.java|/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2|line 75|Java Problem|
|The method buildMessage(String) is undefined for the type Log4j2Logger|Log4j2Logger.java|/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2|line 80|Java Problem|
|The method buildMessage(String) is undefined for the type Log4j2Logger|Log4j2Logger.java|/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2|line 85|Java Problem|
|The method buildMessage(String) is undefined for the type Log4j2Logger|Log4j2Logger.java|/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2|line 90|Java Problem|
|The method getPriority() of type Log4j2Logger must override or implement a supertype method|Log4j2Logger.java|/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2|line 48|Java Problem|
|The method setLogLevel(String, String) in the type Log4j2Logger is not applicable for the arguments (String)|Log4j2Logger.java|/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2|line 64|Java Problem|
|The method setLogLevel(String, String) of type Log4j2Logger must override or implement a supertype method|Log4j2Logger.java|/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2|line 63|Java Problem|
|The method setName(String) of type Log4j2Logger must override or implement a supertype method|Log4j2Logger.java|/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2|line 69|Java Problem|
|The type Log4j2Logger must implement the inherited abstract method Logger.log(Level, String, Throwable)|Log4j2Logger.java|/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2|line 31|Java Problem|

Hm, things are worse than I thought as Liquibase breaks binary compatibility within version 3 from 3.5.3 to 3.10.3:

Description	Resource	Path	Location	Type
PRIORITY_DATABASE cannot be resolved to a variable	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 49	Java Problem
The method buildMessage(String) is undefined for the type Log4j2Logger	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 39	Java Problem
The method buildMessage(String) is undefined for the type Log4j2Logger	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 44	Java Problem
The method buildMessage(String) is undefined for the type Log4j2Logger	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 54	Java Problem
The method buildMessage(String) is undefined for the type Log4j2Logger	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 59	Java Problem
The method buildMessage(String) is undefined for the type Log4j2Logger	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 75	Java Problem
The method buildMessage(String) is undefined for the type Log4j2Logger	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 80	Java Problem
The method buildMessage(String) is undefined for the type Log4j2Logger	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 85	Java Problem
The method buildMessage(String) is undefined for the type Log4j2Logger	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 90	Java Problem
The method getPriority() of type Log4j2Logger must override or implement a supertype method	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 48	Java Problem
The method setLogLevel(String, null) is undefined for the type Logger	LoggingTest.java	/log4j-liquibase/src/test/java/liquibase/ext/logging/log4j2	line 43	Java Problem
The method setLogLevel(String, String) in the type Log4j2Logger is not applicable for the arguments (String)	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 64	Java Problem
The method setLogLevel(String, String) of type Log4j2Logger must override or implement a supertype method	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 63	Java Problem
The method setName(String) is undefined for the type Logger	LoggingTest.java	/log4j-liquibase/src/test/java/liquibase/ext/logging/log4j2	line 42	Java Problem
The method setName(String) of type Log4j2Logger must override or implement a supertype method	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 69	Java Problem
The type Log4j2Logger must implement the inherited abstract method Logger.debug(LogType, String, Throwable)	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 31	Java Problem
The type Log4j2Logger must implement the inherited abstract method Logger.debug(LogType, String)	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 31	Java Problem
The type Log4j2Logger must implement the inherited abstract method Logger.info(LogType, String, Throwable)	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 31	Java Problem
The type Log4j2Logger must implement the inherited abstract method Logger.info(LogType, String)	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 31	Java Problem
The type Log4j2Logger must implement the inherited abstract method Logger.severe(LogType, String, Throwable)	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 31	Java Problem
The type Log4j2Logger must implement the inherited abstract method Logger.severe(LogType, String)	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 31	Java Problem
The type Log4j2Logger must implement the inherited abstract method Logger.warning(LogType, String, Throwable)	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 31	Java Problem
The type Log4j2Logger must implement the inherited abstract method Logger.warning(LogType, String)	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 31	Java Problem

Log4j compiles OK against 3.5.5 but breaks on 3.6.0:

Description	Resource	Path	Location	Type
PRIORITY_DATABASE cannot be resolved to a variable	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 49	Java Problem
The method buildMessage(String) is undefined for the type Log4j2Logger	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 39	Java Problem
The method buildMessage(String) is undefined for the type Log4j2Logger	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 44	Java Problem
The method buildMessage(String) is undefined for the type Log4j2Logger	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 54	Java Problem
The method buildMessage(String) is undefined for the type Log4j2Logger	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 59	Java Problem
The method buildMessage(String) is undefined for the type Log4j2Logger	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 75	Java Problem
The method buildMessage(String) is undefined for the type Log4j2Logger	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 80	Java Problem
The method buildMessage(String) is undefined for the type Log4j2Logger	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 85	Java Problem
The method buildMessage(String) is undefined for the type Log4j2Logger	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 90	Java Problem
The method getPriority() of type Log4j2Logger must override or implement a supertype method	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 48	Java Problem
The method setLogLevel(String, String) in the type Log4j2Logger is not applicable for the arguments (String)	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 64	Java Problem
The method setLogLevel(String, String) of type Log4j2Logger must override or implement a supertype method	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 63	Java Problem
The method setName(String) of type Log4j2Logger must override or implement a supertype method	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 69	Java Problem
The type Log4j2Logger must implement the inherited abstract method Logger.debug(LogType, String, Throwable)	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 31	Java Problem
The type Log4j2Logger must implement the inherited abstract method Logger.debug(LogType, String)	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 31	Java Problem
The type Log4j2Logger must implement the inherited abstract method Logger.info(LogType, String, Throwable)	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 31	Java Problem
The type Log4j2Logger must implement the inherited abstract method Logger.info(LogType, String)	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 31	Java Problem
The type Log4j2Logger must implement the inherited abstract method Logger.severe(LogType, String, Throwable)	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 31	Java Problem
The type Log4j2Logger must implement the inherited abstract method Logger.severe(LogType, String)	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 31	Java Problem
The type Log4j2Logger must implement the inherited abstract method Logger.warning(LogType, String, Throwable)	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 31	Java Problem
The type Log4j2Logger must implement the inherited abstract method Logger.warning(LogType, String)	Log4j2Logger.java	/log4j-liquibase/src/main/java/liquibase/ext/logging/log4j2	line 31	Java Problem

Please advise.
I created Liquibase broke binary compatibility between 3.5.5 and 3.6.0 · Issue #1777 · liquibase/liquibase · GitHub

1 Like

Thanks very much for your response Gary, and the subsequent issue ticket on the Liquibase Github page. I’ve just added a comment to it, to let them know that they can close the original issue I created for this, as yours has more technical detail required for fixing the issue.