Open wleese opened 9 months ago
@wleese Thanks for the request! The "Log Via Console" section in the documentation page contains a bit of information on logging JSON entries to the console which may be relevant to your use case?
@mpeddada1 thanks for the suggestion. I was aware of this feature, however due our multi tenant gke cluster with various kinds of jvm and non jvm applications, we run into the issue of duplicating logs because we’re already pushing all console logging for all apps to gcloud logging.
So in short, we could do this, but all jvm apps that use this would have their logs ingested twice.
@mpeddada1 ah, not duplicated now that I think about it. But the ingesting components would need to deal with both structured and unstructured logs. In addition, one would not have a great experience with kubectl show logs due to the json.
Update: one more reason that finally comes to mind: as mentioned we have a multi tenant gke cluster in 1 gcloud project. We do some usage/cost accounting to “bill” our users. By relying on console logs -> 1 single gcloud project’s logging api / logsink->pubsub->ELK stack, it becomes a bit harder to do usage/cost accounting.
Is your feature request related to a problem? Please describe. When setting up
logback.xml
to usecom.google.cloud.spring.logging.LoggingAppender
, alogger.info(myJsonString)
will lead to a log entry in the Google Cloud Logging UI, with amessage
field containing the value ofmyJsonString
.When this value is JSON and will always be JSON, then putting the value of
myJsonString
in amessage
field results in a sub-optimal experience in Google Cloud Logging UI. The value ofmessage
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.