formatting "gcloud app logs tail" output for structured logs (single line of serialized JSON) in pretty text

230 views Asked by At

I am trying to do structured logging simply with JUL and console handler. As mentioned in google's official documentation https://cloud.google.com/run/docs/logging#using-json I am using single line of serialized JSON with severity and message JSON keys to make logging structured and its working as expected. As a log viewer, I am able to filter logs by severity.

But when I am streaming Logs with gcloud app logs tail I am getting output in this weird format.

<JsonPayloadValue   additionalProperties: [<AdditionalProperty   key: 'thread'   value: <JsonValue   string_value: '16'>>, <AdditionalProperty   key: 'message'   value: <JsonValue   string_value: 'Time taken in smart suggest: 128 ms, Class -> servlets.xyzServlet, Method -> doPost'>>, <AdditionalProperty   key: 'timestamp'   value: <JsonValue   string_value: 'Apr 5, 2021 6:51:11 AM'>>]>

How can i format these json to one linear of pretty text

[Apr 5, 2021 6:51:11 AM] Time taken in smart suggest: 128 ms, class -> servelt.xyzServlet, Method -> doPost'
0

There are 0 answers