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

Migrate Logback configuration class to use suppliers #43588

Closed
philwebb opened this issue Dec 20, 2024 · 4 comments
Closed

Migrate Logback configuration class to use suppliers #43588

philwebb opened this issue Dec 20, 2024 · 4 comments
Assignees
Labels
type: task A general task
Milestone

Comments

@philwebb
Copy link
Member

See qos-ch/logback@be0b5e0 (which triggered qos-ch/logback#885 in Boot 3.4). In 3.5 we could update our code to also use suppliers.

@philwebb philwebb added the type: task A general task label Dec 20, 2024
@philwebb philwebb added this to the 3.5.x milestone Dec 20, 2024
@philwebb philwebb added type: enhancement A general enhancement and removed type: task A general task labels Dec 20, 2024
@ceki
Copy link

ceki commented Dec 21, 2024

@philwebb Please note that the use of suppliers for specifying converter classes is optional. Logback 1.5.14 and later will transparently adapt any converters specified as strings.

@snicoll snicoll self-assigned this Jan 8, 2025
@snicoll
Copy link
Member

snicoll commented Jan 8, 2025

@ceki I am a bit confused about the change. How is the use of suppliers optional? Looking at the code, it looks like that the PATTERN_RULE_REGISTRY map must have a String class name and it will fail if we attempt to use a supplier:

java.lang.ClassCastException: class org.springframework.boot.logging.logback.DefaultLogbackConfiguration$$Lambda$637/0x000000f00132a840 cannot be cast to class java.lang.String (org.springframework.boot.logging.logback.DefaultLogbackConfiguration$$Lambda$637/0x000000f00132a840 is in unnamed module of loader org.springframework.boot.testsupport.classpath.ModifiedClassPathClassLoader @33d05366; java.lang.String is in module java.base of loader 'bootstrap')
	at ch.qos.logback.core.pattern.PatternLayoutBase.migrateFromStringMapToSupplierMap(PatternLayoutBase.java:124)
	at ch.qos.logback.core.pattern.PatternLayoutBase.caterForLegacyConverterMaps(PatternLayoutBase.java:111)
	at ch.qos.logback.core.pattern.PatternLayoutBase.getEffectiveConverterMap(PatternLayoutBase.java:84)
	at ch.qos.logback.core.pattern.PatternLayoutBase.start(PatternLayoutBase.java:143)
	at ch.qos.logback.classic.encoder.PatternLayoutEncoder.start(PatternLayoutEncoder.java:28)
	at org.springframework.boot.logging.logback.LogbackConfigurator.start(LogbackConfigurator.java:110)

What should we do if we want to migrate our code to use suppliers?

@ceki
Copy link

ceki commented Jan 8, 2025

@snicoll I only had 10 minutes to look into this issue this morning. Which version of logback are you using? I am asking because version logback 1.5.14 fixed a compatibility issue when accessing the pattern rule registry through the logging context. Are you using an earlier version of logback by any chance?

The later versions of logback maintain two registries PATTERN_RULE_REGISTRY_FOR_SUPPLIERS and PATTERN_RULE_REGISTRY at the logger context level. When a PatternLayout instance is instantiated, entries from both maps are merged into an effective converter map.

@snicoll
Copy link
Member

snicoll commented Jan 8, 2025

Nope, I am using the latest. But you answered my question. I should change the key to lookup the map.

@wilkinsona wilkinsona added type: task A general task and removed type: enhancement A general enhancement labels Jan 8, 2025
@snicoll snicoll modified the milestones: 3.5.x, 3.5.0-M1 Jan 8, 2025
@snicoll snicoll closed this as completed in b84618f Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: task A general task
Projects
None yet
Development

No branches or pull requests

4 participants