From: Paul Förster <paul.foerster@gmail.com>
To: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: Exclude logging certain connections?
Date: Sun, 15 Mar 2020 17:40:25 +0100
Message-ID: <FE9687AF-03E7-4A83-BE8C-8F16B90D75A2@gmail.com> (raw)
In-Reply-To: <6f368b1c-2422-90bf-012d-9c8162b8fb50@aklaver.com>
References: <1CF8C28E-A9B9-44F6-A849-B3898B8AEAF5@gmail.com>
<6f368b1c-2422-90bf-012d-9c8162b8fb50@aklaver.com>
Hi Adrian,
> Nothing from what I see:
>
> From here:
>
> https://www.postgresql.org/docs/12/config-setting.html#id-1.6.6.4.5
>
> env PGOPTIONS="-c log_connections=off" psql -d test -U aklaver
>
> psql: error: could not connect to server: FATAL: permission denied to set parameter "log_connections"
>
> First problem is you need to be superuser. Alright so be superuser:
>
> date
> Sun Mar 15 09:24:20 PDT 2020
>
> aklaver@maura:~> env PGOPTIONS="-c log_connections=off" psql -d test -U postgres
>
> psql (12.1)
> Type "help" for help.
>
> test=# \x
> Expanded display is on.
> test=# select * from pg_settings where name = 'log_connections';
> -[ RECORD 1 ]---+------------------------------------
> name | log_connections
> setting | off
> unit |
> category | Reporting and Logging / What to Log
> short_desc | Logs each successful connection.
> extra_desc |
> context | superuser-backend
> vartype | bool
> source | client
> min_val |
> max_val |
> enumvals |
> boot_val | off
> reset_val | off
> sourcefile |
> sourceline |
> pending_restart | f
>
>
> The connection is still recorded:
>
> [unknown]-[unknown]-2020-03-15 09:24:23.460 PDT-0LOG: connection received: host=[local]
> [unknown]-postgres-2020-03-15 09:24:23.460 PDT-0LOG: connection authorized: user=postgres database=test application_name=psql
>
>
> To me it looks like log_connections is all or none.
that's what I suspected. This is also what I found out so far. This is ugly because unwanted monitoring connections like those of pgwatch2 keep spamming the logfiles this way. It would be great if there was an option to specify a list of users whose connections would not be logged, even with logging connect/disconnect enabled.
Something like this:
log_exclude_user_connect = 'pgwatch2,myself,...'
in postgresql.conf
Thanks very much.
Cheers,
Paul
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: paul.foerster@gmail.com, adrian.klaver@aklaver.com
Subject: Re: Exclude logging certain connections?
In-Reply-To: <FE9687AF-03E7-4A83-BE8C-8F16B90D75A2@gmail.com>
References: <1CF8C28E-A9B9-44F6-A849-B3898B8AEAF5@gmail.com> <6f368b1c-2422-90bf-012d-9c8162b8fb50@aklaver.com> <FE9687AF-03E7-4A83-BE8C-8F16B90D75A2@gmail.com>
* 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