-SpringBoot 3.3.1 , Java 21, AWS correto. SpringBoot microservice, jar packaging.

-Spring AOT compilation enabled

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
                <executions>
                    <execution>
                        <id>process-aot</id>
                        <goals>
                            <goal>process-aot</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
  • Packaging jar - providing a -Dlogging.config=classpath:logback-xx.xml

java -Dlogging.config=classpath:logback-xx.xml -Dspring.aot.enabled=true -jar ./target/demo-service.jar

When spring.aot is enabled - logback is not loaded at all. When you dont enable aot then logback is picked

Comment From: javapapo

SpringBoot spring.aot.enabled=true breaks logback from loading

Comment From: scottfrederick

When spring.aot is enabled - logback is not loaded at all.

Do you mean that the Logback configuration is not loaded from -Dlogging.config=classpath:logback-xx.xml? If so, then this is the expected behavior.

Logback is supported, including XML configuration. XML configuration is loaded at build time during AOT processing and translated into a fixed, native-friendly format. As a result, loading different XML configuration at runtime is not supported.

If overriding the default Logback config at runtime with AOT isn't the problem you are trying to describe, then please provide a complete example that demonstrates the problem that we can run ourselves and we can re-open the issue.

Comment From: javapapo

Thanks , most probably missed that - the reason I am using the logging.config property is because I want to have a different logback config per Spring profile (dev, prod).

So what is the recommended way to do it? Have a single logback-spring.xml with profiles inside?

@scottfrederick