On 7/25/23 14:43, Wen Yi wrote:
> Hi community,
> When I use the postgres, I check the log.(I use the -l open the log)
> As you can see, I type code like this:
>
> postgres=# show logging_collector;
> logging_collector
> -------------------
> off
> (1 row)
>
> postgres=# ^C
>
> Follow the document, when logging_collector is off, there's no log
> output, but when I check my 'postgres' directory:
>
> [postgres@fedora postgres]$ ls
> build.sh logfile src startdb.sh stopdb.sh update.sh
> [postgres@fedora postgres]$ cat logfile
> 2023-07-24 09:54:59.668 CST [35872] LOG: starting PostgreSQL 17devel on
> x86_64-pc-linux-gnu, compiled by gcc (GCC) 13.1.1 20230614 (Red Hat
> 13.1.1-4), 64-bit
> 2023-07-24 09:54:59.668 CST [35872] LOG: listening on IPv6 address
> "::1", port 5432
> 2023-07-24 09:54:59.668 CST [35872] LOG: listening on IPv4 address
> "127.0.0.1", port 5432
> 2023-07-24 09:54:59.684 CST [35872] LOG: listening on Unix socket
> "/tmp/.s.PGSQL.5432"
> ...
>
> In a word, the log is actually open. (My startup command: pg_ctl -l
> logfile /home/postgres/postgres/bin/bin/pg_ctl -l logfile -D
> /home/postgres/postgres/data start)
> So It's confuse me, the confilt of logging_collector & logfile.
>
> Can someone give me some advice?
https://www.postgresql.org/docs/current/runtime-config-logging.html
Note
It is possible to log to stderr without using the logging collector; the
log messages will just go to wherever the server's stderr is directed.
However, that method is only suitable for low log volumes, since it
provides no convenient way to rotate log files. Also, on some platforms
not using the logging collector can result in lost or garbled log
output, because multiple processes writing concurrently to the same log
file can overwrite each other's output.
https://www.postgresql.org/docs/current/app-pg-ctl.html
-l filename
--log=filename
Append the server log output to filename. If the file does not
exist, it is created. The umask is set to 077, so access to the log file
is disallowed to other users by default.
> Thanks in advance!
>
> Yours,
> Wen Yi
--
Adrian Klaver
adrian.klaver@aklaver.com