From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jerry Sievers <gsievers19@comcast.net>
Cc: Artem Tomyuk <admin@leboutique.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: custom log. variable %h reports [unknown]
Date: Tue, 26 Jan 2016 14:43:16 -0500
Message-ID: <15173.1453837396@sss.pgh.pa.us> (raw)
In-Reply-To: <86bn88urt4.fsf@jerry.enova.com>
References: <CANYYVqJUwtLgG6872XUn=kprifd3J9ZOCBjgTw0HB3npYbG35g@mail.gmail.com>
<86bn88urt4.fsf@jerry.enova.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-admin>
Jerry Sievers <gsievers19@comcast.net> writes:
> Artem Tomyuk <admin@leboutique.com> writes:
>> log_line_prefix = '===========> %h %u %t %p %x: [%l-1]'
>> But in logs i see:
>> ===========> [unknown] 2016-01-26 17:07:46 UTC 1664 0: [1-1]LOG: connection received: host=192.168.112.181 port=50321
> Postmaster.
Good guess, but actually that log entry is emitted in the new backend
process. We do know the remote IP at that point (obviously, because
we show it in the message). But we haven't told elog about it quite
yet. This seems just dumb. I think we should switch the order of
these two stanzas in BackendInitialize():
if (Log_connections)
{
if (remote_port[0])
ereport(LOG,
(errmsg("connection received: host=%s port=%s",
remote_host,
remote_port)));
else
ereport(LOG,
(errmsg("connection received: host=%s",
remote_host)));
}
/*
* save remote_host and remote_port in port structure
*/
port->remote_host = strdup(remote_host);
port->remote_port = strdup(remote_port);
BTW, the [unknown] bit is actually coming from %u, and that's
correct because we've not yet identified the user. AFAICS,
elog just prints nothing for %h when the port->remote_host is
not set yet.
regards, tom lane
--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: tgl@sss.pgh.pa.us, gsievers19@comcast.net, admin@leboutique.com
Subject: Re: custom log. variable %h reports [unknown]
In-Reply-To: <15173.1453837396@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox