Re: custom log. variable %h reports [unknown]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jerry Sievers <gsievers19@xxxxxxxxxxx> writes:
> Artem Tomyuk <admin@xxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux