-
Notifications
You must be signed in to change notification settings - Fork 41k
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
No warning is given when <springProfile> is used in a Logback <root> block #33610
Comments
It's hard to say if this is a Spring Boot issue or related to the fact that Spring Boot 3.0 upgrades to Logback 1.4.x. Please could you provide a sample application as a zip file or GitHub project so that we can take a look. |
@philwebb thank you for your response. I've attached archive with the project that reproduces this behavior. With only this
it successfully prints to the console. With this, no output is observed
By saynig
could you give me the hints where it could be an issue? |
At first I thought that this was a bug with Logback, but I think it's actually an intentional limitation. With the upgrade to Logback 1.4 (see #12649) in Spring Boot 3.0 we needed to refactor the way that If you try and create a similar configuration to yours using <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="test" value="test" />
<appender name="CONSOLE1"
class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>1 - %msg%n</pattern>
</encoder>
</appender>
<if condition='property("test").contains("ignore")'>
<then>
<appender name="CONSOLE2"
class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>2 - %msg%n</pattern>
</encoder>
</appender>
</then>
</if>
<root level="INFO">
<appender-ref ref="CONSOLE1" />
<if condition='property("test").contains("ignore")'>
<then>
<appender-ref ref="CONSOLE2" />
</then>
</if>
</root>
</configuration> Results in
You can read more about this limitation at https://logback.qos.ch/codes.html#nested_if_element We have the same limitation, but we don't currently have a nice For your application, you can follow the advice in https://logback.qos.ch/codes.html#nested_if_element and change your config to use: <springProfile name="docker">
<root level="INFO">
<appender-ref ref="ASYNC_LOGSTASH_CONSOLE" />
</root>
</springProfile>
<springProfile name="!docker">
<root level="INFO">
<appender-ref ref="CONSOLE" />
</root>
</springProfile>
<springProfile name="sentry">
<root level="INFO">
<appender-ref ref="SENTRY" />
</root>
</springProfile> |
I'll leave this open to see if we can add a similar |
Thank you for the support =) |
Hi Community,
I have the following
spring-logback.xml
configurationBefore upgrading to Spring Boot 3.0.0 application successfully logged to the console. However, after upgrade, it stopped doing this.
If I use this configuration
then the app successfully logs message to the console.
The text was updated successfully, but these errors were encountered: