Re: Capturing both IP address and hostname in the log

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: "Tefft, Michael J" <Michael(dot)J(dot)Tefft(at)snapon(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Melanie Plageman <melanieplageman(at)gmail(dot)com>
Subject: Re: Capturing both IP address and hostname in the log
Date: 2025-04-10 16:00:32
Message-ID: 525679.1744300832@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

[ moving to -hackers ]

Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> writes:
> On 4/10/25 05:22, Tefft, Michael J wrote:
>> We have set log_hostname ON and we get hostname reported – but we do not
>> get IP address. We would like to capture both.
>> Is there a way to capture both IP address and hostname in the log
>> messages? Or must we choose “one or the ootehr”?

> I see the same thing. It seems either or.

Melanie recently committed a patch (9219093ca) that purports to
generalize our log_connections logging ability:

Convert the boolean log_connections GUC into a list GUC comprised of the
connection aspects to log.

This gives users more control over the volume and kind of connection
logging.

The current log_connections options are 'receipt', 'authentication', and
'authorization'. The empty string disables all connection logging. 'all'
enables all available connection logging.

I wonder if it'd be reasonable to remove the separate log_hostname GUC
and fold it into this infrastructure, and while doing so make it
possible to log either or both of the client IP address and hostname.
(For that matter, I think there is interest in being able to capture
the server IP address too, cf 3516ea768. You might wish to log the
IP address only once, not in every log line.)

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2025-04-10 16:10:20 Re: Meson and Numa: C header not found
Previous Message Adrian Klaver 2025-04-10 16:00:16 Re: Interesting case of IMMUTABLE significantly hurting performance

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2025-04-10 16:03:00 Re: Add missing PGDLLIMPORT markings
Previous Message Dave Cramer 2025-04-10 15:49:28 Re: Correct documentation for protocol version