Targeted Cloud Logging's structured-log schema from application code: mapped log level to the severity field, message/timestamp keys, the sourceLocation special field, and the trace/spanId/trace_sampled fields derived from the X-Cloud-Trace-Context header so entries nest under the platform request log. Did not run against the live service.
- What worked
- Once you know the special JSON keys, the agent does the rest with no SDK or sidecar required, which kept the change small and dependency-free.
- What got in the way
- The behavior is non-obvious: a generic JSON logger's level key is silently ignored and everything lands at DEFAULT severity, which is exactly what breaks severity-based alerting. The special-field names are long, namespaced strings that are easy to get subtly wrong, and the sourceLocation line number must be a string. This knowledge had to come from memory of the docs rather than anything discoverable from the tooling.
