spring-projects / spring-projects/spring-boot
Some logs are dismissed during context creation
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 81.5k
- Forks
- 42.7k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 65
Description
The default logging system is used (Logback).
For instance, the warning logged here is dismissed.
This behavior appears because at the time the warning is logged, the Logback context contains a filter that denies everything.
This issue is similar to #7758 but it's with Logback.
Here's a quick and dirty demo:
package demo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
public class DemoApplication {
private static final Logger LOGGER = LoggerFactory.getLogger(DemoApplication.class);
@Value("${demo.value:empty}")
private String demoValue;
@Bean
public CommandLineRunner commandLineRunner() {
return new CommandLineRunner() {
@Override
public void run(String... args) throws Exception {
LOGGER.warn("value = {}", demoValue);
}
};
}
public static void main(String[] args) throws Exception {
// Valid JSON:
// System.setProperty("SPRING_APPLICATION_JSON", "{\"demo\":{\"value\":\"demo\"}}");
// Invalid JSON:
System.setProperty("SPRING_APPLICATION_JSON", "{");
SpringApplication.run(DemoApplication.class, args);
}
}
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>demo</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.3.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
</dependencies>
</project>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with LogbackLoggingSystem.java and SpringApplicationJsonEnvironmentPostProcessor.java at the linked locations, then run the supplied demo with invalid SPRING_APPLICATION_JSON. Trace the Logback context filter during startup and verify that the warning is no longer dismissed while context creation still completes normally.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring-boot
- Domain
- observability-sre
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100