Prompt
Why are multiline stack traces getting split across log events?
Latest observation
Oct 28, 2026
OpenAI APIWeb search: off
Multiline stack traces usually get split across separate log events because the logging pipeline is treating each line as an independent event.
Common reasons:
-
The app/logger writes each line separately
- Some frameworks or wrappers emit the exception message and stack trace lines one by one instead of as a single structured event.
-
The log shipper/agent doesn’t have multiline handling configured
- Tools like Fluent Bit, Filebeat, Logstash, Vector, etc. often need a multiline parser/pattern so they know that lines starting with whitespace,
at ..., orCaused by:belong to the previous event.
- Tools like Fluent Bit, Filebeat, Logstash, Vector, etc. often need a multiline parser/pattern so they know that lines starting with whitespace,
-
The platform ingests line-delimited logs
- Many systems assume “one line = one event” when reading stdout/stderr or log files. Without multiline aggregation, stack traces get split.
-
Container/runtime log drivers split on newlines
- In Kubernetes/Docker, logs written to stdout/stderr are frequently captured line-by-line unless your collector recombines them.
-
Transport or formatter strips structure
- If the logger outputs plain text instead of JSON/structured logs, the newline characters are preserved as line breaks and then interpreted as separate records downstream.
How to fix it
- Best option: log exceptions as a single structured event, ideally JSON with an
exceptionfield. - Configure multiline aggregation in the log collector/agent.
- Make sure the application logger emits the entire stack trace in one write, if possible.
- Avoid relying on raw newline-delimited text logs for exception traces.
If you tell me what stack you’re using, I can give the exact multiline config:
- Java + Logback / Log4j
- Python
- Node.js
- Fluent Bit / Filebeat / Logstash / Vector
- Docker / Kubernetes / CloudWatch / ELK