I encountered an issue after updating to Spring Boot version 3.1.3. The problem is related to the Spring profile configuration, specifically the "json-logging" profile, which prevents the application from starting with the new code.

I was able to reproduce the problem locally by following these steps:

  1. Export the environment variable SPRING_PROFILES_ACTIVE: export SPRING_PROFILES_ACTIVE=production,json-logging

  2. Start the application using the command: mvn spring-boot:run

The application starts correctly when the "json-logging" profile is removed:

  1. Export the environment variable SPRING_PROFILES_ACTIVE without "json-logging": export SPRING_PROFILES_ACTIVE=production

  2. Start the application again with the same command: mvn spring-boot:run

This issue seems to be related to the "json-logging" profile when used with Spring Boot 3.1.3. If you need further information or assistance in resolving this issue, please let me know.

logback.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <property name="component.version" value="@version@"/>

    <springProfile name="!json-logging">
        <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
            <layout class="fr.name.log.SingleLinePatternLayout">
                <Pattern>
                    [%logger{10}][${component.version}][%thread][app_name][%X{msgId}][%X{correlationId}][${ENVIRONNEMENT_NAME} - ${HOST_NAME} - NAME] %-5level - %msg%n
                </Pattern>
            </layout>
        </appender>
    </springProfile>

    <springProfile name="json-logging">
        <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
            <encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
                <providers>
                    <pattern>
                        <pattern>
                            {
                            "logger_category":"%logger{10}",
                            "componentVersion":"${component.version}",
                            "thread_name":"%thread",
                            "app_name":"app_name",
                            "env": "${ENVIRONNEMENT_NAME}",
                            "message_id":"%X{msgId}",
                            "correlation_id":"%X{correlationId}",
                            "nom_serveur":"${HOST_NAME}",
                            "asset":"VEC",
                            "level":"%-5level",
                            "message":"%msg",
                            "stack_trace": "%ex{full}"
                            }
                        </pattern>
                    </pattern>
                </providers>
                <!-- to display a formatted stacktrace :  tr '|%' '\n\t' < stacktrace_file -->
                <jsonFactoryDecorator class="net.logstash.logback.decorate.CharacterEscapesJsonFactoryDecorator">
                    <!-- Line feed character -->
                    <escape>
                        <targetCharacterCode>10</targetCharacterCode>
                        <escapeSequence>|</escapeSequence>
                    </escape>
                    <!-- Tab character -->
                    <escape>
                        <targetCharacterCode>9</targetCharacterCode>
                        <escapeSequence>%</escapeSequence>
                    </escape>
                </jsonFactoryDecorator>
            </encoder>
        </appender>
    </springProfile>

    <logger name="fr.comutitres" level="${LOG_LEVEL:-info}">
        <appender-ref ref="STDOUT" />
    </logger>

    <logger name="org.springframework" level="${SPRING_LOG_LEVEL:-warn}">
        <appender-ref ref="STDOUT" />
    </logger>

    <logger name="org.springframework.amqp" level="${SPRING_AMQP_LEVEL:-warn}" additivity="false">
        <appender-ref ref="STDOUT" />
    </logger>

</configuration>

Comment From: wilkinsona

The file that you've shared doesn't work without the json-logging profile active as we do not have access to fr.name.log.SingleLinePatternLayout. If I activate the json-logging profile, name the file logback-spring.xml and configure the root logger:

<root level="INFO">
    <appender-ref ref="STDOUT" />
</root>

I see JSON output as expected:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.1.5)

{"logger_category":"c.e.g.Gh38085Application","componentVersion":"@version@","thread_name":"main","app_name":"app_name","env":"ENVIRONNEMENT_NAME_IS_UNDEFINED","message_id":"","correlation_id":"","nom_serveur":"HOST_NAME_IS_UNDEFINED","asset":"VEC","level":"INFO ","message":"Starting Gh38085Application using Java 17.0.9 with PID 64869 (/Users/awilkinson/Downloads/gh-38085/build/classes/java/main started by awilkinson in /Users/awilkinson/Downloads/gh-38085)","stack_trace":""}
{"logger_category":"c.e.g.Gh38085Application","componentVersion":"@version@","thread_name":"main","app_name":"app_name","env":"ENVIRONNEMENT_NAME_IS_UNDEFINED","message_id":"","correlation_id":"","nom_serveur":"HOST_NAME_IS_UNDEFINED","asset":"VEC","level":"INFO ","message":"The following 2 profiles are active: \"production\", \"json-logging\"","stack_trace":""}
{"logger_category":"c.e.g.Gh38085Application","componentVersion":"@version@","thread_name":"main","app_name":"app_name","env":"ENVIRONNEMENT_NAME_IS_UNDEFINED","message_id":"","correlation_id":"","nom_serveur":"HOST_NAME_IS_UNDEFINED","asset":"VEC","level":"INFO ","message":"Started Gh38085Application in 0.73 seconds (process running for 0.966)","stack_trace":""}

You haven't said how the application is prevented from starting so I can't make any suggestions.

If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.