Re: Proposal: Adding json logging - Mailing list pgsql-hackers

From David Arnold
Subject Re: Proposal: Adding json logging
Date
Msg-id CAH6vsWK7AXcMuyXzkDvzALkrTKZ4QQq8=KMcvXX9yzQc=6XHRQ@mail.gmail.com
Whole thread Raw
In response to Re: Proposal: Adding json logging  (Jordan Deitch <jd@rsa.pub>)
Responses Re: Proposal: Adding json logging  (David Arnold <dar@xoe.solutions>)
List pgsql-hackers
Exactly - arrays, maps, nested json objects. It's more organized and easier to reason about. As postgresql becomes more and more sophisticated over time, I see flat logging becoming more unwieldy. With tools like jq, reading and querying json on the command line is simple and user friendly, and using json for logging capture and aggregation is widely supporting and embraced.

Existence and adoption of jq does certainly make a point here over grep friendly but less structured data.

But I recommend reading over this blog post https://brandur.org/logfmt
It's got some strong arguments over a good log format.
Basically, a good log format is both, human (tail stdaout) and machine (log aggregators) readable. Note how logrus solves the conflict.

El dom., 15 abr. 2018, 10:27 a.m., Jordan Deitch <jd@rsa.pub> escribió:
> > I would suggest that the community consider whether postgres will log
> multidimensional data. That will weigh into the decision of  json vs.
> another format quite significantly. I am a fan of the json5 spec (
> https://json5.org/), though adoption of this is quite poor.
>
> What do you mean by multidimensional data? Arrays/maps?
>
> I think there is no advantage of multidimensional vs prefixed flat logging
> unless data structure gets really nastily nested.
>
> What case where you thinking of?

Exactly - arrays, maps, nested json objects. It's more organized and easier to reason about. As postgresql becomes more and more sophisticated over time, I see flat logging becoming more unwieldy. With tools like jq, reading and querying json on the command line is simple and user friendly, and using json for logging capture and aggregation is widely supporting and embraced.

pgsql-hackers by date:

Previous
From: Jordan Deitch
Date:
Subject: Re: Proposal: Adding json logging
Next
From: David Arnold
Date:
Subject: Re: Proposal: Adding json logging