logback icon indicating copy to clipboard operation
logback copied to clipboard

No Converter classes after logback-access upgrade

Open spellsleeper opened this issue 11 months ago • 4 comments

I tried to upgrade

implementation "net.logstash.logback:logstash-logback-encoder:7.4"
implementation 'ch.qos.logback:logback-access:1.5.12'

to(artifacts were moved)

implementation "net.logstash.logback:logstash-logback-encoder:8.0"
implementation 'ch.qos.logback.access:logback-access-tomcat:2.0.6'
implementation 'ch.qos.logback.access:logback-access-common:2.0.6'

After the upgrade i have a problem with converter classes which looks like:

INFO in ch.qos.logback.core.model.processor.ImplicitModelHandler - Assuming default type [ch.qos.logback.access.common.PatternLayoutEncoder] for [encoder] property 10:51:05,922 |-ERROR in ch.qos.logback.core.pattern.parser.Compiler@12323a9d - There is no conversion class registered for conversion word [h] 10:51:05,922 |-ERROR in ch.qos.logback.core.pattern.parser.Compiler@12323a9d - [h] is not a valid conversion word 10:51:05,922 |-ERROR in ch.qos.logback.core.pattern.parser.Compiler@12323a9d - There is no conversion class registered for conversion word [l] 10:51:05,922 |-ERROR in ch.qos.logback.core.pattern.parser.Compiler@12323a9d - [l] is not a valid conversion word 10:51:05,922 |-ERROR in ch.qos.logback.core.pattern.parser.Compiler@12323a9d - There is no conversion class registered for conversion word [u] 10:51:05,922 |-ERROR in ch.qos.logback.core.pattern.parser.Compiler@12323a9d - [u] is not a valid conversion word 10:51:05,922 |-ERROR in ch.qos.logback.core.pattern.parser.Compiler@12323a9d - There is no conversion class registered for conversion word [t] 10:51:05,922 |-ERROR in ch.qos.logback.core.pattern.parser.Compiler@12323a9d - [t] is not a valid conversion word 10:51:05,922 |-ERROR in ch.qos.logback.core.pattern.parser.Compiler@12323a9d - There is no conversion class registered for conversion word [r] 10:51:05,922 |-ERROR in ch.qos.logback.core.pattern.parser.Compiler@12323a9d - [r] is not a valid conversion word 10:51:05,922 |-ERROR in ch.qos.logback.core.pattern.parser.Compiler@12323a9d - There is no conversion class registered for conversion word [s] 10:51:05,922 |-ERROR in ch.qos.logback.core.pattern.parser.Compiler@12323a9d - [s] is not a valid conversion word 10:51:05,922 |-ERROR in ch.qos.logback.core.pattern.parser.Compiler@12323a9d - There is no conversion class registered for conversion word [b] 10:51:05,922 |-ERROR in ch.qos.logback.core.pattern.parser.Compiler@12323a9d - [b] is not a valid conversion word

and

ERROR in ch.qos.logback.core.pattern.parser.Compiler@7cca6100 - There is no conversion class registered for conversion word [clientHost] 10:51:05,958 |-ERROR in ch.qos.logback.core.pattern.parser.Compiler@7cca6100 - [clientHost] is not a valid conversion word 10:51:05,958 |-ERROR in net.logstash.logback.composite.accessevent.AccessEventPatternJsonProvider@6f10be7d - Invalid [pattern]: Invalid JSON property '//client-host' (was '%clientHost'): Failed to interpret '%clientHost' conversion word. See previous error statuses for more information. net.logstash.logback.pattern.AbstractJsonPatternParser$JsonPatternException: Invalid JSON property '//client-host' (was '%clientHost'): Failed to interpret '%clientHost' conversion word. See previous error statuses for more information. at net.logstash.logback.pattern.AbstractJsonPatternParser$JsonPatternException: Invalid JSON property '//client-host' (was '%clientHost'): Failed to interpret '%clientHost'

Before the upgrade in ch.qos.logback.core.pattern.parser.Compiler 69 converter classes were loaded. After the upgrade 0. The old conversion classes don't exist any more. It seems they've got a new package - ch.qos.logback.access.pattern vs. ch.qos.logback.access.common.pattern. But in this package are not all necessary converter classes(only 31)

Is there a known way how to get the necessary converter classes with the upgraded dependencies? Is there a necessary additional dependency?

logback converter classes before

logback converter classes now

logback-access

spellsleeper avatar Jan 14 '25 13:01 spellsleeper

A colleague of me fixed the problem. The logback default for logback-core was 1.5.12. ext['logback.version'] = '1.5.16' fixed the problem. Was the same problem like in https://github.com/qos-ch/logback/issues/885

spellsleeper avatar Jan 16 '25 09:01 spellsleeper

However, it would of course be nice if it worked without this workaround. It's the wrong default version in Spring Boot

spellsleeper avatar Jan 16 '25 09:01 spellsleeper

@spellsleeper Spring Boot team released 3.4.2 just 4 hours ago where they bumped logback.version from 1.5.12 to 1.5.16, so the version override won't be needed anymore.

arogulin avatar Jan 23 '25 17:01 arogulin

When upgrading to Spring Boot 3.4.2, we got the following error

java.lang.IllegalStateException: java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in net.logstash.logback.composite.loggingevent.LoggingEventPatternJsonProvider@120bb5b5 - Invalid [pattern]: Invalid JSON property '//version' (was '%replace(%property{build.version}){'null',''}'): class java.lang.String cannot be cast to class java.util.function.Supplier (java.lang.String and java.util.function.Supplier are in module java.base of loader 'bootstrap') net.logstash.logback.pattern.AbstractJsonPatternParser$JsonPatternException: Invalid JSON property '//version' (was '%replace(%property{build.version}){'null',''}'): class java.lang.String cannot be cast to class java.util.function.Supplier (java.lang.String and java.util.function.Supplier are in module java.base of loader 'bootstrap')

And our configuration looks like

provider<LoggingEventPatternJsonProvider> {
    isOmitEmptyFields = true
    this.pattern = """
{
    "type": "Service",
    "name": "%mdc{component}",
    "version": "%replace(%property{build.version}){'null',''}"
}
"""
}

jackie-linz avatar Feb 03 '25 04:02 jackie-linz

You need to align the version of logback-access with logback-core. In a Spring-boot application, that means you need to specify the dependencies and their version instead of relying on the spring-boot-parent or spring-boot-dependencies (which is good practice anyways).

Version 1.5.13 introduced getDefaultConverterSupplierMap to replace the deprecated method getDefaultConverterMap. See this comparison

This was aligned in logback-access from v2.0.5 See this comparison Unfortunately the deprecated method implementation was replaced with an empty Map.

Conclusion: use either logback-core 1.5.12 with logback-access 2.0.4 or logback-core 1.5.13 (and up) with logback-access 2.0.5 (and up)

TomVanWemmel avatar Mar 11 '25 09:03 TomVanWemmel

@jackie-linz We're hitting the same issue on upgrading Spring Boot, and I opened a new issue about it since I think it's a related, but slightly different case:

https://github.com/qos-ch/logback/issues/931

jordanjennings avatar Apr 02 '25 20:04 jordanjennings