Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u2usm-007jm5-Kp for pgsql-hackers@arkaria.postgresql.org; Thu, 10 Apr 2025 16:36:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1u2usl-00EUfH-0s for pgsql-hackers@arkaria.postgresql.org; Thu, 10 Apr 2025 16:36:03 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u2usk-00EUf9-JE for pgsql-hackers@lists.postgresql.org; Thu, 10 Apr 2025 16:36:03 +0000 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u2usj-0045aR-0T for pgsql-hackers@lists.postgresql.org; Thu, 10 Apr 2025 16:36:02 +0000 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-2c1c9b7bd9aso577318fac.0 for ; Thu, 10 Apr 2025 09:36:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744302960; x=1744907760; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=t9rNbKwLXdXBxrhgQM5yPm05avLNe7o3xKm12Qdmd7M=; b=e7I+moK1cejqgYbYn+pABXlgX89YFpavr4QQlaQvzbHA4dH5x9m5DvjkWdAGYyqNqb MniBO0YVdKOc09HaSycAWI3NqV8F88XMMme4VjjDV9QIsk/fZIn3V99Nobmx7FAINyzT hoLWxJ7Eu/Qx4MwgaNS/Q+si/0GpV0bTAHKkFeo/0O0Z6owYQx5fDZ+b61ijMNpvjIpG RGcOH4YfObyr+EV3jngrDyo4uuourHVupvzJXR4ItckXmSgWUyHONs79v24KXq75eMTR XbzEvUM6yeto0Jiv0qSKPFuJLh0zfZ3YJDx8HEbIC/bPam+2rTv4DMzYG9Kl8FPap2Uo vZtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744302960; x=1744907760; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=t9rNbKwLXdXBxrhgQM5yPm05avLNe7o3xKm12Qdmd7M=; b=dtX5SDG2dgtyzozmKorC9YYBW59htzBLaT8s0Dt5ffhqANI1zSRfcijXiBF1Hlk844 qAPBd8It0IF0Lv3dq/ngw0qbBsM6vgUWguBXdf+1SEPjaraTLaJks3kHOZzWbBRhD0Gq QKIyFexUgVmDZ4eI9ZNBqhE8AX4qPUVKHmkrqUkPL1wVpUioh/Wf3UVoiOqefv6q/Rsi RvYA0sIDo1LKHJDr6eH8p+2+at90KFUliZIhwccbBd0erLpukYsbSq0/NDcnavVnrw02 2sGzYXmQGk2gwItqgpMG55y7T4Y6zM+HFlWEqWeAqFS90Sj9DtTg2K3xp49n1922KD0v T7mQ== X-Forwarded-Encrypted: i=1; AJvYcCXy6kZYmgwOjjVhYcro/JByFvpRwj+VOcdevBSzaySkO+zyZe4aPWGNTewhexWoHDLEq6Cb1yQvcWTiONd2@lists.postgresql.org X-Gm-Message-State: AOJu0YyTmfMkbnLQf54kLMnd+wdFKkEQYjptEFMAE0w+/hIpp8RP9IUz LSiBRXXznDEvfXCwn4aoX7vJUh8bSD3jfoccyRNEXvgJa4QV0SVnIYlTNYTmJTdds/uLsHllWDo NIHf6zOvk60wjqee9LHvDgj1ZJhY= X-Gm-Gg: ASbGnct7C5HoXvYetgMAzLXPQ5IkrvE7qga+1g8vXL6K8jk8Eb7Xkc2bD8sCuLKLQ7o ZucwRYYXBIKqAQw8tpqMOMec1iLqGzf01DCfpxxu59RJK7YaJQ5TsWD0E4CWN6zkgp7JsBbpdrR dheJqUd0gDjxgJ4mS6hWMD X-Google-Smtp-Source: AGHT+IEESpBnEdTt4u7P9PqEP7nfJvfhqkvdxcqMf+NUcu3k+O4A8XCsXkm8JUs1gVhnUZC1bMN7z9iwaVL93RD4SUA= X-Received: by 2002:a05:6870:ce8a:b0:2c6:7f82:d38c with SMTP id 586e51a60fabf-2d0b5e318c6mr1872628fac.31.1744302960556; Thu, 10 Apr 2025 09:36:00 -0700 (PDT) MIME-Version: 1.0 References: <97cfc252-9a26-489e-b458-999ac5589224@aklaver.com> <525679.1744300832@sss.pgh.pa.us> In-Reply-To: <525679.1744300832@sss.pgh.pa.us> From: "David G. Johnston" Date: Thu, 10 Apr 2025 09:35:23 -0700 X-Gm-Features: ATxdqUE2XpwCraD4SZ8h0uvQIAKfrTF9doqqdhSvEmsYoIzuzNKgn0GP2MW8iLE Message-ID: Subject: Re: Capturing both IP address and hostname in the log To: Tom Lane Cc: Adrian Klaver , "Tefft, Michael J" , pgsql-hackers@lists.postgresql.org, Melanie Plageman Content-Type: multipart/alternative; boundary="0000000000005847cb06326f2eed" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000005847cb06326f2eed Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Apr 10, 2025 at 9:00=E2=80=AFAM Tom Lane wrote: > [ moving to -hackers ] > > Adrian Klaver writes: > > On 4/10/25 05:22, Tefft, Michael J wrote: > >> We have set log_hostname ON and we get hostname reported =E2=80=93 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 =E2=80=9Cone or the ootehr=E2=80=9D? > > > I see the same thing. It seems either or. > cross-posting to -hackers now that it is here. v19 plans aside the existing wording is incorrect (just here, other places correctly point out the either-or aspect of the output). The wording really should be more like: diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index fea683cb49..c545fee6c9 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -7614,10 +7614,11 @@ local0.* /var/log/postgresql - By default, connection log messages only show the IP address of th= e - connecting host. Turning this parameter on causes logging of the - host name as well. Note that depending on your host name resolution - setup this might impose a non-negligible performance penalty. + By default, for TCP/IP-originated connections, the identifier of the host + making the connection is its IP address. Turning this parameter on tells + the system to record the resolved host name instead. Note that depending + on your host name resolution setup this might impose a non-negligible + performance penalty. This parameter can only be set in the postgresql.conf file or on the server command line. Both the connection logging routine and log_line_prefix %h / %r simply report the "identifier of the host making the connection". David J. --0000000000005847cb06326f2eed Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Apr 10, 2025 at 9:00=E2=80=AFAM Tom Lane <tgl@sss.pgh.pa.us> wrote:
[ moving to -hackers ]

Adrian Klaver <adrian.klaver@aklaver.com> writes:
> On 4/10/25 05:22, Tefft, Michael J wrote:
>> We have set log_hostname ON and we get hostname reported =E2=80=93= 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 =E2=80=9Cone or the ootehr=E2=80=9D?
> I see the same thing. It seems either or.

cross-posting to -hackers now that it is here.

v= 19 plans aside the existing wording is incorrect (just here, other places c= orrectly point out the either-or aspect of the output).

<= div class=3D"gmail_default" style=3D"font-family:arial,helvetica,sans-serif= ">The wording really should be more like:

diff --git a/doc/src/sgml/= config.sgml b/doc/src/sgml/config.sgml
index fea683cb49..c545fee6c9 1006= 44
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@= @ -7614,10 +7614,11 @@ local0.* =C2=A0 =C2=A0/var/log/postgresql
=C2=A0 = =C2=A0 =C2=A0 =C2=A0</term>
=C2=A0 =C2=A0 =C2=A0 =C2=A0<listite= m>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 <para>
- =C2=A0 =C2=A0 =C2=A0= =C2=A0By default, connection log messages only show the IP address of the<= br>- =C2=A0 =C2=A0 =C2=A0 =C2=A0connecting host. Turning this parameter on = causes logging of the
- =C2=A0 =C2=A0 =C2=A0 =C2=A0host name as well.=C2= =A0 Note that depending on your host name resolution
- =C2=A0 =C2=A0 =C2= =A0 =C2=A0setup this might impose a non-negligible performance penalty.
= + =C2=A0 =C2=A0 =C2=A0 =C2=A0By default, for TCP/IP-originated connections,= the identifier of the host
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0making the conn= ection is its IP address.=C2=A0 Turning this parameter on tells
+ =C2=A0= =C2=A0 =C2=A0 =C2=A0the system to record the resolved host name instead.= =C2=A0 Note that depending
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0on your host nam= e resolution setup this might impose a non-negligible
+ =C2=A0 =C2=A0 = =C2=A0 =C2=A0performance penalty.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0This= parameter can only be set in the <filename>postgresql.conf</filen= ame>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0file or on the server command = line.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 </para>


Both the conn= ection logging routine and log_line_prefix %h / %r simply report the "= identifier of the host making the connection".

David J.

--0000000000005847cb06326f2eed--