Prompt

How do I parse multiline stack traces into searchable logs?

Technology / Observability1 observationLast seen Oct 22, 2026

Latest observation

Oct 22, 2026OpenAI APIWeb search: off

To make multiline stack traces searchable, the key is to keep each exception as a single log event instead of splitting it into separate lines.

Common approaches

1) Emit structured logs if possible

Best option: log exceptions as JSON with fields like:

  • timestamp
  • level
  • message
  • exception.type
  • exception.message
  • exception.stack_trace

This makes search and filtering much easier than raw text.


2) Use multiline parsing in your log collector

If your app writes plain text stack traces, configure your log shipper/parser to join related lines into one event.

Typical multiline rule:

  • Treat a line starting with a timestamp / log prefix as the start of a new event
  • Any line that does not match that pattern gets appended to the previous line

Example pattern idea

If your logs start like:

2026-10-22 12:00:01 INFO Starting app
2026-10-22 12:00:05 ERROR Something failed
java.lang.NullPointerException: boom
    at com.example.Foo.bar(Foo.java:12)
    at com.example.App.main(App.java:8)
2026-10-22 12:00:06 INFO Recovering

Use the timestamp line as the delimiter so the exception block becomes one record.


3) Preserve stack traces as escaped newlines

If you’re sending logs directly to a searchable system:

  • replace actual newlines with \n
  • store the entire stack trace in one field

Example:

{
  "level": "ERROR",
  "message": "Something failed",
  "stack_trace": "java.lang.NullPointerException: boom\n    at com.example.Foo.bar(Foo.java:12)\n    at com.example.App.main(App.java:8)"
}

How to do it in popular tools

Fluent Bit / Fluentd

Use a multiline parser that groups lines based on a regex match for the first line of a log event.

Logstash

Use the multiline codec or preprocess in Filebeat/Fluent Bit before sending.

Filebeat

Use the multiline configuration to join stack trace lines into one event.

Docker / Kubernetes

If logs are split by container runtime, configure your collector to merge multiline output before indexing.


Good multiline parsing rules

A reliable “start of event” line often includes:

  • timestamp
  • log level
  • thread name
  • logger name

Example regex:

^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}

Then:

  • new event if line matches regex
  • append otherwise

Important cautions

  • Don’t rely only on indentation; stack traces vary by language and framework
  • Make sure your parser handles:
    • Caused by:
    • Suppressed:
    • nested exceptions
    • Python tracebacks
    • JavaScript async stack traces
  • Avoid splitting on blank lines alone, since many logs contain blank lines normally

Recommended best practice

  1. Use structured JSON logs
  2. If not possible, configure multiline parsing at the ingestion layer
  3. Store stack traces in a dedicated field for search and filtering

If you want, I can give you a ready-to-use multiline config for:

  • Elasticsearch/Filebeat
  • Logstash
  • Fluent Bit
  • Python
  • Java / Logback
  • Kubernetes logs

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.