how to find log

Started by Dmitry Markmanabout 5 years ago4 messages
#1Dmitry Markman
dmarkman@mac.com

Hi all

suppose I started the server with the following command

pg_ctl -D . . . start -l <logfilename>

is there a way to get <logfilename> later by sending some query to the server or

reading some configuration file

(for example I can get data directory with the query “show data_directory”)

thanks in advance

Dimitry Markman

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Dmitry Markman (#1)
Re: how to find log

Dmitry Markman <dmarkman@mac.com> writes:

suppose I started the server with the following command
pg_ctl -D . . . start -l <logfilename>
is there a way to get <logfilename> later by sending some query to the server or

No, the server has no way to know where its stdout/stderr were
pointed to. You might want to enable the syslogger output method
(see logging_collector) to have something a bit more featureful.

https://www.postgresql.org/docs/current/runtime-config-logging.html

regards, tom lane

#3Andrew Dunstan
andrew@dunslane.net
In reply to: Tom Lane (#2)
Re: how to find log

On 12/20/20 11:31 AM, Tom Lane wrote:

Dmitry Markman <dmarkman@mac.com> writes:

suppose I started the server with the following command
pg_ctl -D . . . start -l <logfilename>
is there a way to get <logfilename> later by sending some query to the server or

No, the server has no way to know where its stdout/stderr were
pointed to. You might want to enable the syslogger output method
(see logging_collector) to have something a bit more featureful.

https://www.postgresql.org/docs/current/runtime-config-logging.html

Alternatively, asking the OS in many cases will work, e.g. on my linux
machine:

ls -l /proc/{postmasterpid}/fd/1

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

#4Dmitry Markman
dmarkman@mac.com
In reply to: Andrew Dunstan (#3)
Re: how to find log

Thanks Tom, Andrew
I’ll try out logging_collector facility

thanks again

dm

Show quoted text

On Dec 20, 2020, at 12:04 PM, Andrew Dunstan <andrew@dunslane.net> wrote:

On 12/20/20 11:31 AM, Tom Lane wrote:

Dmitry Markman <dmarkman@mac.com> writes:

suppose I started the server with the following command
pg_ctl -D . . . start -l <logfilename>
is there a way to get <logfilename> later by sending some query to the server or

No, the server has no way to know where its stdout/stderr were
pointed to. You might want to enable the syslogger output method
(see logging_collector) to have something a bit more featureful.

https://www.postgresql.org/docs/current/runtime-config-logging.html

Alternatively, asking the OS in many cases will work, e.g. on my linux
machine:

ls -l /proc/{postmasterpid}/fd/1

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com