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

Default Logback config uses deprecated "converterClass" attribute #42006

Closed
eu-rlarsen opened this issue Aug 23, 2024 · 6 comments
Closed

Default Logback config uses deprecated "converterClass" attribute #42006

eu-rlarsen opened this issue Aug 23, 2024 · 6 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@eu-rlarsen
Copy link

eu-rlarsen commented Aug 23, 2024

After the logback 1.5.7 upgrade, a deprecated warning is now shown:

01:56:52,355 |-INFO in ch.qos.logback.core.joran.util.ConfigurationWatchListUtil@17f9344b - Adding [jar:file:/Users/Shared/.m2/repository/org/springframework/boot/spring-boot/3.3.3/spring-boot-3.3.3.jar!/org/springframework/boot/logging/logback/defaults.xml] to configuration watch list.
01:56:52,355 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@315ba14a - URL [jar:file:/Users/Shared/.m2/repository/org/springframework/boot/spring-boot/3.3.3/spring-boot-3.3.3.jar!/org/springframework/boot/logging/logback/defaults.xml] is not of type file
01:56:52,357 |-WARN in ch.qos.logback.core.joran.action.ConversionRuleAction - [converterClass] attribute is deprecated and replaced by [class]. See element [conversionRule] near line 8
01:56:52,357 |-WARN in ch.qos.logback.core.joran.action.ConversionRuleAction - [converterClass] attribute is deprecated and replaced by [class]. See element [conversionRule] near line 9
01:56:52,357 |-WARN in ch.qos.logback.core.joran.action.ConversionRuleAction - [converterClass] attribute is deprecated and replaced by [class]. See element [conversionRule] near line 10
01:56:52,357 |-WARN in ch.qos.logback.core.joran.action.ConversionRuleAction - [converterClass] attribute is deprecated and replaced by [class]. See element [conversionRule] near line 11
01:56:52,357 |-WARN in ch.qos.logback.core.joran.action.ConversionRuleAction - [converterClass] attribute is deprecated and replaced by [class]. See element [conversionRule] near line 12

Which are the below lines in: org/springframework/boot/spring-boot/3.3.3/spring-boot-3.3.3.jar!/org/springframework/boot/logging/logback/defaults.xml

<conversionRule conversionWord="applicationName" converterClass="org.springframework.boot.logging.logback.ApplicationNameConverter" />
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
<conversionRule conversionWord="correlationId" converterClass="org.springframework.boot.logging.logback.CorrelationIdConverter" />
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 23, 2024
@sgyyz
Copy link

sgyyz commented Aug 23, 2024

The 3.3.2 is fine but the 3.3.3 got these outputs.

@nikooooooooooooooooooo
Copy link

nikooooooooooooooooooo commented Aug 23, 2024

The logback prompt is obvious because converterClass is abandoned and replaced by class

    public static String CONVERTER_CLASS_ATTRIBUTE = "converterClass";

    protected boolean validPreconditions(SaxEventInterpretationContext seic, String name, Attributes attributes) {
        PreconditionValidator pv = new PreconditionValidator(this, seic, name, attributes);
        boolean invalidConverterClassAttribute = pv.isInvalidAttribute(CONVERTER_CLASS_ATTRIBUTE);
        boolean invalidClassAttribute = pv.isInvalidAttribute("class");
        if (!invalidConverterClassAttribute) {
            String var10001 = CONVERTER_CLASS_ATTRIBUTE;
            pv.addWarn("[" + var10001 + "] attribute is deprecated and replaced by [class]. " + pv.getLocationSuffix());
        }

        boolean missingClass = invalidClassAttribute && invalidConverterClassAttribute;
        if (missingClass) {
            pv.addMissingAttributeError("class");
            return false;
        } else {
            boolean multipleClassAttributes = !invalidClassAttribute && !invalidConverterClassAttribute;
            if (multipleClassAttributes) {
                pv.addWarn("Both [" + CONVERTER_CLASS_ATTRIBUTE + "] attribute and [class] attribute specified. ");
                pv.addWarn("[class] attribute will override. ");
            }

            pv.validateGivenAttribute("conversionWord");
            return pv.isValid();
        }
    }

org/springframework/boot/logging/logback/defaults.xml

    <conversionRule conversionWord="clr" class="org.springframework.boot.logging.logback.ColorConverter"/>
    <conversionRule conversionWord="wex" class="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
    <conversionRule conversionWord="wEx" class="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>

can define the conversionRule yourself, instead of using the default defaults.xml

@snicoll
Copy link
Member

snicoll commented Aug 23, 2024

Thanks for the report.

See #41887, this can be reproduced by adding <include resource="org/springframework/boot/logging/logback/defaults.xml" /> - default setup isn't affected.

@snicoll snicoll changed the title Fix deprecated logback config Default Logback config uses deprecated "convererClass" Aug 23, 2024
@snicoll snicoll added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 23, 2024
@snicoll snicoll added this to the 3.3.4 milestone Aug 23, 2024
@snicoll snicoll self-assigned this Aug 23, 2024
@bclozel bclozel changed the title Default Logback config uses deprecated "convererClass" Default Logback config uses deprecated "converterClass" attribute Aug 23, 2024
@knoobie
Copy link

knoobie commented Aug 23, 2024

I've also seen a lot of noise while starting an application now.. also related to this or something other / new?

Boot 3.3.3


[INFO] --- spring-boot:3.3.3:run (default-cli) @ project---
[INFO] Attaching agents: []
09:25:56,902 |-INFO in ch.qos.logback.classic.LoggerContext[default] - This is logback-classic version 1.5.7
09:25:56,905 |-INFO in ch.qos.logback.classic.util.ContextInitializer@433d61fb - Here is a list of configurators discovered as a service, by rank: 
09:25:56,905 |-INFO in ch.qos.logback.classic.util.ContextInitializer@433d61fb -   org.springframework.boot.logging.logback.RootLogLevelConfigurator

….. 300 Lines more.. until ASCII art / real application logs starts.

,--.  ,--.,--.   ,--.,------.    ,------.,--.    ,---.                         ,--.

compared to 3.3.2 or below

```log

[INFO] --- spring-boot:3.3.2:run (default-cli) @ project---
[INFO] Attaching agents: []
,--.  ,--.,--.   ,--.,------.    ,------.,--.    ,---.                         ,--.

@wilkinsona
Copy link
Member

wilkinsona commented Aug 23, 2024

It's the same problem. The WARN level messages cause all of the status messages to be output, to aid problem diagnosis. You can work around it as @564142183 suggested above, by replacing the include of defaults.xml with your own equivalent configuration.

@knoobie
Copy link

knoobie commented Aug 23, 2024

Thanks Andy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

7 participants