Introduction
A word related to structured logging has been around for a while. As additional log analysis and managing solutions hit the market, the practice gains popularity. Structured logging has replaced many well-known proprietary formatting systems.

Structured logging is the process of giving application logs a standardized, preset message format that enables them to be handled as data sets rather than text.
Structured logging is defined in a wide variety of ways. The concept of representing each log entry as an object or record so it can be processed and searched by automated tools is at the core of structured logging. The ingested structured logs are often parsed and saved as objects using a preset text or binary format, such as JSON, XML, or Protocol Buffers (protobuf). From the beginning, Google Cloud uses structured logging. The LogEntry structure in Google Cloud serves as a log description. With Log Explorer or through Logging APIs, the logs can be searched for and examined. It is possible to use Log Analytics for more intricate analysis or to export log entries to BigQuery.
How to write logs
Depending on the log management tool, the local logging framework, and the application environment, different approaches are used when an application sends logs to a remote destination. Cloud Logging makes the Logging v2 API available, which can be accessed directly over REST or gRPC or by utilizing special Logging framework adapters.
Additionally, Google offers logging client libraries for usage by developers. These choices import logs into the Cloud Logging backend directly. Additionally, it is possible to "assign" the task of log ingestion to logging agents running on one of the Google Cloud platforms.
AppEngine, GKE, Cloud Run, Cloud Function, Cloud Build, DataProc, and DataFlow are the platforms with logging agents. On GCE instances, the agent must be explicitly installed before it can be set up to allow log capturing as well. By simply outputting logs to stdout or stderr while an application is operating on the platform with the logging agent, it is possible to ingest them into Cloud Logging.
The agents are capable of capturing both structured and plain text payloads. It is recommended to format the supported structured payload as a single-line JSON string. The agent can parse and save special fields from the payload in the context information fields (e.g. httpRequest).
The following details are inaccessible when entered into the special fields:
- When writing a structured payload to stdout, it is not feasible to alter the log's name or destination.
- The resource field is filled in by the agent automatically. This field cannot be customized in any way.