Comments (2)
My suspicion when discussing this will @OlgaMaciaszek and @sdeleuze was that this would be due to our deferred logging but that doesn't appear to be the case.
As far as I can tell, the problem is that the failure is occurring before we've had a chance to initialize Logback and Logback in its default configuration doesn't work in a native image. This means that this error logging is silent:
Via some primitive debugging (adding System.out
calls to a copy of SpringApplication
) I've confirmed that this is an instance of org.apache.commons.logging.LogAdapter$Slf4jLocationAwareLog
as we would expect and that error logging is enabled.
Further primitive debugging has shown that the problem is that Logback has no appenders configured. Things are in this state as Logback cannot load its various built-in configurator classes:
ch.qos.logback.classic.joran.SerializedModelConfigurator
ch.qos.logback.classic.util.DefaultJoranConfigurator
ch.qos.logback.classic.BasicConfigurator
When running on the JVM, BasicConfigurator
creates a ConsoleAppender
to which the error is logged. In a native image, BasicConfigurator
cannot be loaded so Logback's left without any appenders and the event is silently dropped.
from spring-boot.
None of the three configurator classes could be loaded because NBT 0.9.8 uses a version of the Logback reachability metadata that does not allow them to be loaded reflectively. NBT 0.10.1 fixes this for two of the three configurators by using a more up-to-date version of the metadata by default. The metadata is missing reflection configuration for ch.qos.logback.classic.BasicConfigurator
so it doesn't completely address the problem. This will have to be fixed in the reachability metadata and oracle/graalvm-reachability-metadata#454 is tracking that.
In the meantime, the problem can be worked around by using NBT 0.10.1 and an additional runtime hint:
package com.example;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ImportRuntimeHints;
import com.example.NativeImageLoggingApplication.AdditionalLogbackHints;
import ch.qos.logback.classic.BasicConfigurator;
@SpringBootApplication
@ImportRuntimeHints(AdditionalLogbackHints.class)
public class NativeImageLoggingApplication {
public static void main(String[] args) {
SpringApplication.run(NativeImageLoggingApplication.class, args);
}
static class AdditionalLogbackHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
hints.reflection().registerType(BasicConfigurator.class, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS);
}
}
}
from spring-boot.
Related Issues (20)
- x-www-form-urlencoded escaping leads to truncated request HOT 1
- Trigger docs build when artifacts are published
- Add caching to docs-build
- Upgrade from 3.0.13 to 3.1.10 - SSL setup through jvm properties broken HOT 3
- JDK22 and GraalVM spring-boot:3.2.4:build-image failed: Builder lifecycle 'creator' failed with status code 51 HOT 1
- Graceful Shutdown behavior ambiguity in Reference Guide
- Clarify that all named properties must match for @ConditionalOnProperty to match HOT 2
- Getting 500 instead of 404 with integration tests when updating from Spring Boot 3.1.x to to 3.2.4 HOT 6
- Bump gradle/wrapper-validation-action from 2.1.1 to 2.1.2
- Bump gradle/wrapper-validation-action from 2.1.1 to 2.1.2
- Remove redundant Regex escapes
- Remove redundant Regex escapes
- Remove redundant Regex escapes
- Verify snapshots once they have been deployed
- Verify snapshots once they have been deployed
- Verify snapshots once they have been deployed
- Upgrade to Gradle Enterprise Conventions 0.0.16
- Reference Guides breadcrumb in page headers is not hyperlinked HOT 1
- Make it harder to misconfigure logging.threshold.console in yaml HOT 3
- Executable JAR application startup is slower after 3.2.0 when Hibernate scanner is not disabled HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-boot.