Sometimes it's handy to turn on really verbose Postgres logging, but
then to filter the log. I've lately been using 'tail -F' to monitor
the log, and then filtering with grep, utilizing log_line_prefix to
distinguish our various applications (eg by username or
application_name). The problem with this approach is that sometimes a
single log entry goes over multiple lines. When that happens, I get
just up to the first newline, losing anything else.
GNU grep has a handy '-z' option to look for a zero terminator as the
end of a "record". I tried putting \0 at the beginning of
log_line_prefix but Postgres interpreted that as an empty prefix.
Currently my best result is to start log_line_prefix with \1 and pipe
tail into a translator that turns \1 into \0 (not the default Linux
'tr' as it's too buffered) and THEN into grep, but this feels clunky.
Is there a convenient way to mark log entries for grepping like this?
I googled for various things, but "null", "zero", and "log" all have
rather a lot of meanings :) Alternatively, this may be a feature
request: support %z meaning \0, or perhaps a separate log directive to
end with a null. Is that possible?
Thanks in advance!
Chris Angelico