Structured logging

In Cloud Logging, a LogEntry object can store a log payload as either structured data or unstructured text. A structured log entry stores its payload as a JSON object in the jsonPayload field, whereas an unstructured log entry stores its payload as a string in the textPayload field.

Formatting your log payload as a JSON object lets you search and query by JSON paths in the Logs Explorer. With unstructured logs, you can search the text string, but you can't query individual keys.

How structured logs are written

How structured log entries are written to Logging depends on your environment and how your logs are collected:

  • Logging client libraries: These libraries write structured logs when you pass a JSON object or map as the payload, or when they output single-line JSON to stdout or stderr.

What's next