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