Re: Logging which local address was connected to in log_line_prefix

Robert Haas <robertmhaas@gmail.com>

From: Robert Haas <robertmhaas@gmail.com>
To: Greg Sabino Mullane <htamfids@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Jim Jones <jim.jones@uni-muenster.de>, david@pgmasters.net, Peter Eisentraut <peter@eisentraut.org>, Cary Huang <cary.huang@highgo.ca>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2025-04-07T15:39:01Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Add local-address escape "%L" to log_line_prefix.

On Sun, Apr 6, 2025 at 8:50 PM Greg Sabino Mullane <htamfids@gmail.com> wrote:
> I lean for #1. Yes, there is some inconsistency, but it feels like the right thing to do, and this is a feature I suspect not many people will use anyway.

I just saw the commit message here and thought I would show up to say
that it sounds like a cool feature. I agree that not many people will
use it, but when you need it, you're probably going to be really happy
to have it.

The only thing that makes me a little bit sad is that we don't seem to
have added this to pg_stat_activity. I feel like that would be the
dream here: in the rare situation where you're not sure which
interface is connecting to a client, having this in pg_stat_activity
would allow you to clarify the situation without needing to change
your logging. Maybe it's not super-important; in a pinch, at least on
Linux, you can probably use netstat to figure out what's happening.
However, putting it in pg_stat_activity would, at least for me, would
make the information routinely available without extra steps. If you
have to ask a user to run an extra tool, they have to have it
installed and know how to use it and run it at the same time they
collect the pg_stat_activity data and so on; if you just add a column
to pg_stat_activity then the information just shows up as part of
routine data gathering.

-- 
Robert Haas
EDB: http://www.enterprisedb.com