Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Minor] Slf4j Detection with Slf4j 1.8/2.0 #2984

Closed
A248 opened this issue Oct 21, 2020 · 1 comment
Closed

[Minor] Slf4j Detection with Slf4j 1.8/2.0 #2984

A248 opened this issue Oct 21, 2020 · 1 comment
Assignees
Milestone

Comments

@A248
Copy link

A248 commented Oct 21, 2020

I just thought I would let you know that Slf4j 1.8.0/2.0.0 no longer uses org.slf4j.impl.StaticLoggerBinder, therefore this line in FeatureDetector will fail to detect these versions of Slf4j.

Instead, slf4j will rely on the ServiceLoader mechanism to find the logger factory:

More specifically, when initializing the LoggerFactory class will no longer search for the StaticLoggerBinder class on the class path. – http://www.slf4j.org/faq.html#changesInVersion18

As a result Flyway will not detect slf4j although this is the intention of LogCreatorFactory.


Bug template:

Which version and edition of Flyway are you using?

Flyway 7.0.4 community edition

If this is not the latest version, can you reproduce the issue with the latest one as well?

(Many bugs are fixed in newer releases and upgrading will often resolve the issue)
7.0.4 is the latest as of writing this

Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)

Java API

Which database are you using (type & version)?

HSQLDB 2.5.1

Which operating system are you using?

Mac OS X

What did you do?

Run this:

package flywaydb.slf4j2;

import org.flywaydb.core.internal.util.FeatureDetector;

public class FlywaySlf4j2Main {

	public static void main(String[] args) {
		boolean slf4j = new FeatureDetector(FlywaySlf4j2Main.class.getClassLoader()).isSlf4jAvailable();
		System.out.println("Has slf4j: " + slf4j);
	}
	
}
What did you expect to see?

"Has slf4j: true" using slf4j 1.8.0/2.0.0

What did you see instead?

"Has slf4j: false" using slf4j 1.8.0/2.0.0

When using slf4j 1.7.30, it is correctly detected.

@juliahayward
Copy link
Contributor

This isn't as easy as it might seem. When using the AWS SDK for S3 storage, that embeds a version of the SLF4J API (at 1.7, natch) which gets picked up by the feature detector. Looking for the StaticLoggerBinder made sure there was a concrete implementation underlying the Logger, and taking out that check results in

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

when trying to use S3, with log output going to the console. We'll carry on looking, but there may be wider ramifications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants