2

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'
Prateek Gupta
  • 119
  • 2
  • 7
  • Do you mean to change output of `gcloud app logs tail` command? or you want to find other way to process the logs? – vitooh Apr 12 '21 at 13:41
  • @vitooh currently I am processing logs by parsing the log tail output using awk parser. I just wanted to get text in pretty format. Can i change output of log tail also? what do you mean by change? – Shivendra Pratap Singh Apr 16 '21 at 06:21
  • I think this could be good idea for Feature Request. Please raise on [Public Issue Tracker](https://cloud.google.com/sdk/docs/getting-support#file_bugs_or_feature_requests). – vitooh Apr 21 '21 at 05:58

0 Answers0