GoogleCloudPlatform / GoogleCloudPlatform/spring-cloud-gcp
In Google Cloud Logging I'd like to emit structured json via com.google.cloud.spring.logging.LoggingAppender
- Dominant language
- Java
- Stars
- 551
- Forks
- 349
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 14
Description
**Is your feature request related to a problem? Please describe.**
When setting up `logback.xml` to use `com.google.cloud.spring.logging.LoggingAppender`, a `logger.info(myJsonString)` will lead to a log entry in the Google Cloud Logging UI, with a `message` field containing the value of `myJsonString`.
When this value is JSON and will always be JSON, then putting the value of `myJsonString` in a `message` field results in a sub-optimal experience in Google Cloud Logging UI. The value of `message` will not be recognized as JSON, and will not benefit from being treated as a structured log (no nifty grey triangles to expand/collapse fields within the JSON).
**Describe the solution you'd like**
I'd like the ability to configure `com.google.cloud.spring.logging.LoggingAppender` so that its input is considered JSON at all times, having it use the log event message as the payload.
**Describe alternatives you've considered**
Alternatively, I can create my own log appender, but this is wasteful for the relatively small change this is likely to be.
I also looked into how a string value could be considered a structural log (json) using the Google Cloud Logging UI, but this doesn't seem possible.
Contributor guide
Research direction
Start with com.google.cloud.spring.logging.LoggingAppender and the logback.xml configuration described in the issue, tracing how logger.info(myJsonString) becomes the message field. Define the configuration behavior for treating the log event message as JSON, then verify that Google Cloud Logging displays the fields as structured data rather than only under message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- google-cloud, java, spring
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100