I built and maintain a logging starter for my company, and am in the process of updating it for Spring Boot 3.0. I've found that Janino fails to leverage Spring properties while evaluating conditions. Here is my demo project that reproduces the issue: https://github.com/matthenry87/logback-janino-bug
While debugging, I can see the property in the logging context's property map:
(breakpoint at line 191 of LogbackLoggingSystem.java)
But you can see in the statuses variable that the condition is evaluating to false when it should be true:
The logging configuration itself can use the property for element values just fine, it just seems that Janino isn't properly receiving them.
Comment From: philwebb
This looks like a filter ordering problem. Our SpringPropertyModelHandler is being added behind a DenyAll filter so it doesn't run early enough.
Changing the order addModelHandlerAssociations in SpringBootJoranConfigurator to the following appears to fix things:
@Override
protected void addModelHandlerAssociations(DefaultProcessor defaultProcessor) {
defaultProcessor.addHandler(SpringPropertyModel.class,
(handlerContext, handlerMic) -> new SpringPropertyModelHandler(this.context,
this.initializationContext.getEnvironment()));
defaultProcessor.addHandler(SpringProfileModel.class,
(handlerContext, handlerMic) -> new SpringProfileModelHandler(this.context,
this.initializationContext.getEnvironment()));
super.addModelHandlerAssociations(defaultProcessor);
}
I'd like to add some tests before making that change.
Comment From: philwebb
@matthenry87 have you found the issue only occurs with Spring Boot 3? Are early versions of Spring Boot OK?
Comment From: matthenry87
@matthenry87 have you found the issue only occurs with Spring Boot 3? Are early versions of Spring Boot OK?
My Janino conditionals in logback-spring.xml work fine prior to migrating to 3 (we're on 2.7.x, and the starter has existed for a couple years now).