diff options
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/maintenance.sgml | 34 | ||||
-rw-r--r-- | doc/src/sgml/ref/pg_ctl-ref.sgml | 13 |
2 files changed, 45 insertions, 2 deletions
diff --git a/doc/src/sgml/maintenance.sgml b/doc/src/sgml/maintenance.sgml index 4a68ec3b404..02c512f8bcd 100644 --- a/doc/src/sgml/maintenance.sgml +++ b/doc/src/sgml/maintenance.sgml @@ -932,8 +932,8 @@ analyze threshold = analyze base threshold + analyze scale factor * number of tu program if you have one that you are already using with other server software. For example, the <application>rotatelogs</application> tool included in the <productname>Apache</productname> distribution - can be used with <productname>PostgreSQL</productname>. To do this, - just pipe the server's + can be used with <productname>PostgreSQL</productname>. One way to + do this is to pipe the server's <systemitem>stderr</systemitem> output to the desired program. If you start the server with <command>pg_ctl</command>, then <systemitem>stderr</systemitem> @@ -946,6 +946,36 @@ pg_ctl start | rotatelogs /var/log/pgsql_log 86400 </para> <para> + You can combine these approaches by setting up <application>logrotate</application> + to collect log files produced by <productname>PostgreSQL</productname> built-in + logging collector. In this case, the logging collector defines the names and + location of the log files, while <application>logrotate</application> + periodically archives these files. When initiating log rotation, + <application>logrotate</application> must ensure that the application + sends further output to the new file. This is commonly done with a + <literal>postrotate</literal> script that sends a <literal>SIGHUP</literal> + signal to the application, which then reopens the log file. + In <productname>PostgreSQL</productname>, you can run <command>pg_ctl</command> + with the <literal>logrotate</literal> option instead. When the server receives + this command, the server either switches to a new log file or reopens the + existing file, depending on the logging configuration + (see <xref linkend="runtime-config-logging-where"/>). + </para> + + <note> + <para> + When using static log file names, the server might fail to reopen the log + file if the max open file limit is reached or a file table overflow occurs. + In this case, log messages are sent to the old log file until a + successful log rotation. If <application>logrotate</application> is + configured to compress the log file and delete it, the server may lose + the messages logged in this timeframe. To avoid this issue, you can + configure the logging collector to dynamically assign log file names + and use a <literal>prerotate</literal> script to ignore open log files. + </para> + </note> + + <para> Another production-grade approach to managing log output is to send it to <application>syslog</application> and let <application>syslog</application> deal with file rotation. To do this, set the diff --git a/doc/src/sgml/ref/pg_ctl-ref.sgml b/doc/src/sgml/ref/pg_ctl-ref.sgml index 304a64d6a60..e31275a04e2 100644 --- a/doc/src/sgml/ref/pg_ctl-ref.sgml +++ b/doc/src/sgml/ref/pg_ctl-ref.sgml @@ -99,6 +99,13 @@ PostgreSQL documentation <cmdsynopsis> <command>pg_ctl</command> + <arg choice="plain"><option>logrotate</option></arg> + <arg choice="opt"><option>-D</option> <replaceable>datadir</replaceable></arg> + <arg choice="opt"><option>-s</option></arg> + </cmdsynopsis> + + <cmdsynopsis> + <command>pg_ctl</command> <arg choice="plain"><option>kill</option></arg> <arg choice="plain"><replaceable>signal_name</replaceable></arg> <arg choice="plain"><replaceable>process_id</replaceable></arg> @@ -227,6 +234,12 @@ PostgreSQL documentation </para> <para> + <option>logrotate</option> mode rotates the server log file. + For details on how to use this mode with external log rotation tools, see + <xref linkend="logfile-maintenance"/>. + </para> + + <para> <option>kill</option> mode sends a signal to a specified process. This is primarily valuable on <productname>Microsoft Windows</productname> which does not have a built-in <application>kill</application> command. Use |