Re: Setting log_connection in connection string doesn't work - Mailing list pgsql-hackers

From Kyotaro Horiguchi
Subject Re: Setting log_connection in connection string doesn't work
Date
Msg-id 20211027.102405.1336553917010534751.horikyota.ntt@gmail.com
Whole thread Raw
In response to Re: Setting log_connection in connection string doesn't work  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Setting log_connection in connection string doesn't work  (Michael Paquier <michael@paquier.xyz>)
List pgsql-hackers
At Tue, 26 Oct 2021 09:39:12 -0400, Tom Lane <tgl@sss.pgh.pa.us> wrote in 
> Kyotaro Horiguchi <horikyota.ntt@gmail.com> writes:
> > I noticed that the following command doesn't leave connection log in
> > log file.
> >> psql "host=localhost options=-c\ log_connections=on"
> 
> [ shrug... ]  Why would you expect it to?  Should "-c log_connections=off"
> be able to hide a connection from the log?

I don't know. The fact is that it's a superuser-backend variable that
is silently ignored (but acutally seems to be set in the session).
Setting log_disconnection the same way works (of course the impliction
of this is far less significant that the log_connection case).

If we want to refuse them to be set at session start (and I think so),
shouldn't they be changed to SIGHUP? (I forgot to mention this choice
in the previous mail..)

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index e91d5a3cfd..57d810c80d 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -1353,7 +1353,7 @@ static struct config_bool ConfigureNamesBool[] =
         NULL, NULL, NULL
     },
     {
-        {"log_connections", PGC_SU_BACKEND, LOGGING_WHAT,
+        {"log_connections", PGC_SIGHUP, LOGGING_WHAT,
             gettext_noop("Logs each successful connection."),
             NULL
         },
@@ -1362,7 +1362,7 @@ static struct config_bool ConfigureNamesBool[] =
         NULL, NULL, NULL
     },
     {
-        {"log_disconnections", PGC_SU_BACKEND, LOGGING_WHAT,
+        {"log_disconnections", PGC_SIGHUP, LOGGING_WHAT,
             gettext_noop("Logs end of a session, including duration."),
             NULL
         },

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: heads up: initdb.exe now succeeds in wine
Next
From: Japin Li
Date:
Subject: Re: [PATCH v2] src/port/snprintf.c: Optimize the common base=10 case in fmtint