Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jDW8E-0008Dr-9O for pgsql-general@arkaria.postgresql.org; Sun, 15 Mar 2020 16:28:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jDW8A-0000OD-Uh for pgsql-general@arkaria.postgresql.org; Sun, 15 Mar 2020 16:28:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jDW88-0000LD-UW for pgsql-general@lists.postgresql.org; Sun, 15 Mar 2020 16:28:50 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jDW80-0001C7-G0 for pgsql-general@lists.postgresql.org; Sun, 15 Mar 2020 16:28:48 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 6243D695; Sun, 15 Mar 2020 12:28:36 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 15 Mar 2020 12:28:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm2; bh=W JRoUFyMzIzmssHhyMP5zAYx+9u8dghdRIfdn08GyqY=; b=FGD2HOSDXVaC6BxMJ dmTgUjxFD2dX0F90K3BWUsLNAg1/S/EVcYxkeHHoTBGqKtkwxqnTg64tX6cCNxtn GJ98hbAYwKuftdJNVaKkVIaiX9q6ml8ZVJ2iXn3tBnbFvMghVm4bNS6g09DzpkWH 9GWdrb5U9F27E04mdWILdafxI4pgQ5w4iK1pvWMVuyZJGHOVRrAtJh5OdDidp22g Oxk4qe5aQged4kcttRtWpySJXHZfMRuFyipuxV353ag2TTemhx9CYDOlpM+mo2dq j9J8CgxXiuP/TzVDa05uJimqLmmBwZUK5S1Tz9Xlircf3/3BwJkENhXw/my7NkRK 5LlzQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=WJRoUFyMzIzmssHhyMP5zAYx+9u8dghdRIfdn08Gy qY=; b=dGryU4ypqZtgl3avnreuVRl0v8Ld8oHWlwq1FcLG86NbqIcIq/SEGlKGE FtZ6wkvmrfePvWf+xoQxpvgF98Glza+YxiQJVOQSq89CeXHMSJ2+uvszZ+cK7QJk XUgM7xumJlj3fWK5QtlfJn/uVDcdEek0wemJ90gRA5FvzOEbgeX+hYnNhWkHiEqP RJ5dvbXTU13GOBpZk5/vzZ1pOBICbSn5wRg79uioxeN/GMd3Xj/ZsMVCylDuo3GG qWF+ZpEW2avJ1Zl9FNAftj0XFBB0E43d0Hp0/8NyVY8t2rvhnMZW6PwNKQ795G5W RITrBv2WvgU9pb7jjiJbM02U4YrdA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrudeftddgvddthecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepuffvfhfhkffffgggjggtgfesth ekredttdefjeenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdr khhlrghvvghrsegrkhhlrghvvghrrdgtohhmqeenucffohhmrghinhepshhtrggtkhgvgi gthhgrnhhgvgdrtghomhdpphhoshhtghhrvghsqhhlrdhorhhgnecukfhppeejuddrvddu vddruddvledrudelfeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Received: from [192.168.1.10] (unknown [71.212.129.193]) by mail.messagingengine.com (Postfix) with ESMTPA id 728F63061856; Sun, 15 Mar 2020 12:28:35 -0400 (EDT) Subject: Re: Exclude logging certain connections? To: =?UTF-8?Q?Paul_F=c3=b6rster?= , pgsql-general References: <1CF8C28E-A9B9-44F6-A849-B3898B8AEAF5@gmail.com> From: Adrian Klaver Message-ID: <6f368b1c-2422-90bf-012d-9c8162b8fb50@aklaver.com> Date: Sun, 15 Mar 2020 09:28:34 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <1CF8C28E-A9B9-44F6-A849-B3898B8AEAF5@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 3/15/20 3:09 AM, Paul Förster wrote: > Hi, > > is there a way to exclude certain connections, for example recurring monitoring connections, from the postgres.log? > > I found this from in old post on stackexchange.com: > > postgres=# create role mon login; > CREATE ROLE > postgres=# alter role mon set log_connections=off; > ERROR: parameter "log_connections" cannot be set after connection start > > (source: https://dba.stackexchange.com/questions/118018/is-it-possible-to-exclude-specific-users-in-log-activity-of-postgresql) > > There is no connection at the time. So why do I get the error? And what can I do about it? 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. > > Cheers, > Paul > -- Adrian Klaver adrian.klaver@aklaver.com