Re: Logging which local address was connected to in log_line_prefix
Jim Jones <jim.jones@uni-muenster.de>
From: Jim Jones <jim.jones@uni-muenster.de>
To: Greg Sabino Mullane <htamfids@gmail.com>
Cc: 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-03-02T18:26:10Z
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 →
-
Add local-address escape "%L" to log_line_prefix.
- 3516ea768c92 18.0 landed
On 27.02.25 14:54, Greg Sabino Mullane wrote: > Great question. I think "supposed to" is a bit of a stretch, but I > presume it's the difference between a client connecting and using its > connection information versus an already existing backend process, > which is always going to be "local". > > Overall this makes sense, as that checkpoint example above is coming > from the checkpointer background process at 3114981, not the backend > process that happened to trigger it. And 3114981 has no way of knowing > the details of the caller's connection. > In that case, it LGTM. I revisited this patch and tested it with two different computers (for client and server). Initially, I was momentarily confused by the logged address format, which varies depending on the client's format. However, I found that %h behaves just like this, so I guess it is ok. postgres=# SHOW log_line_prefix; log_line_prefix ----------------------- %m [%p]: L=%L, h=%h (1 row) 2025-03-02 18:19:07.859 CET [2246150]: L=192.168.178.27, h=192.168.178.79 ERROR: division by zero 2025-03-02 18:19:07.859 CET [2246150]: L=192.168.178.27, h=192.168.178.79 STATEMENT: SELECT 1/0 2025-03-02 18:19:19.327 CET [2246291]: L=2a02:...:7591, h=2a02:...:4a7 ERROR: division by zero 2025-03-02 18:19:19.327 CET [2246291]: L=2a02:...:7591, h=2a02:...:4a7 STATEMENT: SELECT 1/0 Best, Jim