Thread: Non-default postgresql.conf values to log

Non-default postgresql.conf values to log

From
Alex Ignatov
Date:
Hello!
For example in oracle alert.log file we have:
...
System parameters with non-default values:
   processes                = 300
   nls_language             = "AMERICAN"
   nls_territory            = "RUSSIA"
   memory_target            = 720M
   control_files            = "/ora/oradata/orcl/control01.ctl"
...
My question is: is there any option(s) to log non-default
postgresql.conf values to log file?



--
Alex Ignatov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company



Re: Non-default postgresql.conf values to log

From
Christoph Moench-Tegeder
Date:
## Alex Ignatov (a.ignatov@postgrespro.ru):

> My question is: is there any option(s) to log non-default
> postgresql.conf values to log file?

Depending on your use case, I'd start with a simple query:
SELECT name, setting FROM pg_settings WHERE source <> 'default'
Wrap that in a COPY, or perhaps it's good enough to have it in
the database at all times anyway...

Regards,
Christoph

--
Spare Space


Re: Non-default postgresql.conf values to log

From
Tom Lane
Date:
Alex Ignatov <a.ignatov@postgrespro.ru> writes:
> My question is: is there any option(s) to log non-default
> postgresql.conf values to log file?

No, but you can easily find all the non-default settings by querying
the pg_settings view.

            regards, tom lane


Re: Non-default postgresql.conf values to log

From
Alex Ignatov
Date:

On 07.04.2016 16:53, Tom Lane wrote:
> Alex Ignatov <a.ignatov@postgrespro.ru> writes:
>> My question is: is there any option(s) to log non-default
>> postgresql.conf values to log file?
> No, but you can easily find all the non-default settings by querying
> the pg_settings view.
>
>             regards, tom lane

Yeah, i know it but pg_settings is available only after pg is ready to
accept client connections.
Also in some cases log file is placed on another server say, syslog. And
if your pg server is not available you cant say anything about your
pg_settings.

--
Alex Ignatov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company



Re: Non-default postgresql.conf values to log

From
Rob Sargent
Date:

> On Apr 7, 2016, at 8:26 AM, Alex Ignatov <a.ignatov@postgrespro.ru> wrote:
>
>
>
>> On 07.04.2016 16:53, Tom Lane wrote:
>> Alex Ignatov <a.ignatov@postgrespro.ru> writes:
>>> My question is: is there any option(s) to log non-default
>>> postgresql.conf values to log file?
>> No, but you can easily find all the non-default settings by querying
>> the pg_settings view.
>>
>>            regards, tom lane
>
> Yeah, i know it but pg_settings is available only after pg is ready to accept client connections.
> Also in some cases log file is placed on another server say, syslog. And if your pg server is not available you cant
sayanything about your pg_settings. 

At that point you're looking in a file: log file or config file. Does it matter which?
> --
> Alex Ignatov
> Postgres Professional: http://www.postgrespro.com
> The Russian Postgres Company
>
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general


Re: Non-default postgresql.conf values to log

From
Alex Ignatov
Date:

On 07.04.2016 17:59, Rob Sargent wrote:
>
>> On Apr 7, 2016, at 8:26 AM, Alex Ignatov <a.ignatov@postgrespro.ru> wrote:
>>
>>
>>
>>> On 07.04.2016 16:53, Tom Lane wrote:
>>> Alex Ignatov <a.ignatov@postgrespro.ru> writes:
>>>> My question is: is there any option(s) to log non-default
>>>> postgresql.conf values to log file?
>>> No, but you can easily find all the non-default settings by querying
>>> the pg_settings view.
>>>
>>>             regards, tom lane
>> Yeah, i know it but pg_settings is available only after pg is ready to accept client connections.
>> Also in some cases log file is placed on another server say, syslog. And if your pg server is not available you cant
sayanything about your pg_settings. 
> At that point you're looking in a file: log file or config file. Does it matter which?
>> --
>> Alex Ignatov
>> Postgres Professional: http://www.postgrespro.com
>> The Russian Postgres Company
>>
>>
>>
>> --
>> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-general
>
It matter when your pg host is down and all you have is log file. It is
very usual situation. You need historical info.

--
Alex Ignatov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company



Re: Non-default postgresql.conf values to log

From
"David G. Johnston"
Date:
On Thu, Apr 7, 2016 at 10:06 AM, Alex Ignatov <a.ignatov@postgrespro.ru> wrote:
It matter when your pg host is down and all you have is log file. It is very usual situation. You need historical info.

​I think this would be a good idea.  Is it something you are thinking of writing now that you see PostgreSQL does not have the capability?  I'd imagine it would default to OFF and/or would only happen when/if the database couldn't start successfully.

David J.

Re: Non-default postgresql.conf values to log

From
"David G. Johnston"
Date:
On Thu, Apr 7, 2016 at 10:37 AM, David G. Johnston <david.g.johnston@gmail.com> wrote:
On Thu, Apr 7, 2016 at 10:06 AM, Alex Ignatov <a.ignatov@postgrespro.ru> wrote:
It matter when your pg host is down and all you have is log file. It is very usual situation. You need historical info.

​I think this would be a good idea.  Is it something you are thinking of writing now that you see PostgreSQL does not have the capability?  I'd imagine it would default to OFF and/or would only happen when/if the database couldn't start successfully.


​Admittedly, I'm not sure how you would fix any problems without access to the server and its config files - at which point you are back to simply reviewing those.

I'm not sure how much merit "historical info" has and how one would configure the server to ensure that said info is available when/if eventually needed.
David J.

Re: Non-default postgresql.conf values to log

From
Adrian Klaver
Date:
On 04/07/2016 10:06 AM, Alex Ignatov wrote:
>
>
> On 07.04.2016 17:59, Rob Sargent wrote:
>>
>>> On Apr 7, 2016, at 8:26 AM, Alex Ignatov <a.ignatov@postgrespro.ru>
>>> wrote:
>>>
>>>
>>>
>>>> On 07.04.2016 16:53, Tom Lane wrote:
>>>> Alex Ignatov <a.ignatov@postgrespro.ru> writes:
>>>>> My question is: is there any option(s) to log non-default
>>>>> postgresql.conf values to log file?
>>>> No, but you can easily find all the non-default settings by querying
>>>> the pg_settings view.
>>>>
>>>>             regards, tom lane
>>> Yeah, i know it but pg_settings is available only after pg is ready
>>> to accept client connections.
>>> Also in some cases log file is placed on another server say, syslog.
>>> And if your pg server is not available you cant say anything about
>>> your pg_settings.
>> At that point you're looking in a file: log file or config file. Does
>> it matter which?
>>> --
>>> Alex Ignatov
>>> Postgres Professional: http://www.postgrespro.com
>>> The Russian Postgres Company
>>>
>>>
>>>
>>> --
>>> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
>>> To make changes to your subscription:
>>> http://www.postgresql.org/mailpref/pgsql-general
>>
> It matter when your pg host is down and all you have is log file. It is
> very usual situation. You need historical info.

So you are logging to another computer, otherwise if the host is down
how are you getting the log?

In any case Postgres does log changes to parameters in its log file:

-2016-04-07 10:39:21.868 PDT-0LOG:  received SIGHUP, reloading
configuration files
-2016-04-07 10:39:21.869 PDT-0LOG:  parameter "log_statement" changed to
"all"
-2016-04-07 10:44:42.930 PDT-0LOG:  received SIGHUP, reloading
configuration files
-2016-04-07 12:44:42.989 CDT-0LOG:  parameter "log_timezone" changed to
"US/Central
-2016-04-07 12:45:29.966 CDT-0LOG:  parameter "log_statement" changed to
"mod"
-2016-04-07 10:45:29.966 PDT-0LOG:  parameter "log_timezone" changed to
"US/Pacific"

>


--
Adrian Klaver
adrian.klaver@aklaver.com


Re: Non-default postgresql.conf values to log

From
Tom Lane
Date:
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> ​Admittedly, I'm not sure how you would fix any problems without access to
> the server and its config files - at which point you are back to simply
> reviewing those.

Yeah.  Other related problems include being unable to *find* the log file
if you don't know what the server configuration is.

There is already a "postgres -C guc_name" option if you want to find out
from the command line what value a particular GUC is set to by the
cluster's configuration files.  I could see some value in a variant of
that that prints all GUCs with non-default sources.  But that would go
to stdout in any case.  Wanting it to go into a log file sounds to me
a whole lot like wanting to duplicate some Oracle-based DBA habits at a
bug-compatible level.

(Note also that there's already logging of on-the-fly *changes* in
configuration file settings, so I'm not buying the "historical info"
angle at all.)

            regards, tom lane