From: | Chris Angelico <rosuav(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Null-terminated log entries? |
Date: | 2012-09-04 03:52:59 |
Message-ID: | CAPTjJmrVPGM2zP6a23rosxouQPZDjd1FzJP9LwrFzwFXCoimbA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Harshitha S | 2012-09-04 04:15:04 | Re: [GENERAL] Reduce the time to know trigger_file's existence |
Previous Message | Bruce Momjian | 2012-09-04 02:53:02 | Re: [GENERAL] Date conversion using day of week |