Skip to content
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

Missing Logs in Catch Blocks When Using Structured Logging (ECS Format) in Spring Boot 3.4.x #34352

Open
srasantos opened this issue Feb 1, 2025 · 0 comments
Labels
status: waiting-for-triage An issue we've not yet triaged or decided on

Comments

@srasantos
Copy link

srasantos commented Feb 1, 2025

When enabling structured logging with the ECS format in a Spring Boot 3.4.2 (also occurs with 3.4.0 and 3.4.1) application, log statements inside catch blocks are completely missing from both the console and file outputs.
Consider the following snippet:

public void mymethod() {
    log.atInfo()
        .addKeyValue("operation", "mymethod")
        .log("Start processing data message");

    try {
        // Some code here that throws an exception
    } catch (final Exception e) {
        log.atInfo()
            .addKeyValue("operation", "mymethod")
            .log("Unable to process the message.");
    }
}

Expected Behavior

  • Both log statements should appear in the console and log file.
  • The first log message ("Start processing data message") appears as expected.
  • The second log message ("Unable to process the message.") inside the catch block should also be logged.

Actual Behavior

  • The first log message appears as expected.
  • The log message inside the catch block never appears in the console or log file.
  • Other logs in the application continue to be logged normally.

Observations & Confirmations

  • The exception is definitely thrown (verified using e.printStackTrace(), which prints the stack trace correctly).
  • Disabling structured logging restores normal behavior—logs inside the catch block appear as expected.
  • The issue occurs with formats ecs and logstash but not with gelf
  • The application continues logging normally for other requests—only log statements that follow an exception are missing.
  • We got the same behaviour using version 3.4.0 and 3.4.1
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged or decided on
Projects
None yet
Development

No branches or pull requests

2 participants