Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf6d2783

Browse files
committed
Improve documentation of log rotation options, per Ed L.
1 parent915351e commitf6d2783

File tree

1 file changed

+30
-11
lines changed

1 file changed

+30
-11
lines changed

‎doc/src/sgml/runtime.sgml

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.280 2004/08/31 04:53:43 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.281 2004/09/17 22:40:46 tgl Exp $
33
-->
44

55
<Chapter Id="runtime">
@@ -1929,16 +1929,16 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Win32
19291929
<term><varname>log_filename</varname> (<type>string</type>)</term>
19301930
<listitem>
19311931
<para>
1932-
When <varname>redirect_stderr</> is enabled, this option
1932+
When <varname>redirect_stderr</varname> is enabled, this option
19331933
sets the file names of the created log files. The value
1934-
is treated as a <systemitem>strftime</> pattern,
1935-
so <literal>%</>-escapes
1934+
is treated as a <systemitem>strftime</systemitem> pattern,
1935+
so <literal>%</literal>-escapes
19361936
can be used to specify time-varying file names.
1937-
If no <literal>%</>-escapes are present,
1937+
If no <literal>%</literal>-escapes are present,
19381938
<productname>PostgreSQL</productname> will
19391939
append the epoch of the new log file's open time. For example,
1940-
if <varname>log_filename</> were <literal>server_log</>, then the
1941-
chosen file name would be <literal>server_log.1093827753</>
1940+
if <varname>log_filename</varname> were <literal>server_log</literal>, then the
1941+
chosen file name would be <literal>server_log.1093827753</literal>
19421942
for a log starting at Sun Aug 29 19:02:33 2004 MST.
19431943
This option can only be set at server start or in the
19441944
<filename>postgresql.conf</filename> configuration file.
@@ -1950,7 +1950,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Win32
19501950
<term><varname>log_rotation_age</varname> (<type>integer</type>)</term>
19511951
<listitem>
19521952
<para>
1953-
When <varname>redirect_stderr</> is enabled, this option
1953+
When <varname>redirect_stderr</varname> is enabled, this option
19541954
determines the maximum lifetime of an individual log file.
19551955
After this many minutes have elapsed, a new log file will
19561956
be created. Set to zero to disable time-based creation of
@@ -1965,7 +1965,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Win32
19651965
<term><varname>log_rotation_size</varname> (<type>integer</type>)</term>
19661966
<listitem>
19671967
<para>
1968-
When <varname>redirect_stderr</> is enabled, this option
1968+
When <varname>redirect_stderr</varname> is enabled, this option
19691969
determines the maximum size of an individual log file.
19701970
After this many kilobytes have been emitted into a log file,
19711971
a new log file will be created. Set to zero to disable size-based
@@ -1980,19 +1980,38 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Win32
19801980
<term><varname>log_truncate_on_rotation</varname> (<type>boolean</type>)</term>
19811981
<listitem>
19821982
<para>
1983-
When <varname>redirect_stderr</> is enabled, this option will cause
1983+
When <varname>redirect_stderr</varname> is enabled, this option will cause
19841984
<productname>PostgreSQL</productname> to truncate (overwrite),
19851985
rather than append to, any existing log file of the same name.
19861986
However, truncation will occur only when a new file is being opened
19871987
due to time-based rotation, not during server startup or size-based
19881988
rotation. When false, pre-existing files will be appended to in
19891989
all cases. For example, using this option in combination with
1990-
a <varname>log_filename</> like <literal>postgresql-%H.log</>
1990+
a <varname>log_filename</varname> like <literal>postgresql-%H.log</literal>
19911991
would result in generating twenty-four hourly log files and then
19921992
cyclically overwriting them.
19931993
This option can only be set at server start or in the
19941994
<filename>postgresql.conf</filename> configuration file.
19951995
</para>
1996+
<para>
1997+
Example: To keep 7 days of logs, one log file per day named
1998+
<literal>server_log.Mon</literal>, <literal>server_log.Tue</literal>,
1999+
etc, and automatically overwrite last week's log with this week's log,
2000+
set <varname>log_filename</varname> to <literal>server_log.%a</literal>,
2001+
<varname>log_truncate_on_rotation</varname> to <literal>true</literal>, and
2002+
<varname>log_rotation_age</varname> to <literal>1440</literal>.
2003+
</para>
2004+
<para>
2005+
Example: To keep 24 hours of logs, one log file per hour, but
2006+
also rotate sooner if the log file size exceeds 1GB, set
2007+
<varname>log_filename</varname> to <literal>server_log.%H%M</literal>,
2008+
<varname>log_truncate_on_rotation</varname> to <literal>true</literal>,
2009+
<varname>log_rotation_age</varname> to <literal>60</literal>, and
2010+
<varname>log_rotation_size</varname> to <literal>1000000</literal>.
2011+
Including <literal>%M</> in <varname>log_filename</varname> allows
2012+
any size-driven rotations that may occur to select a filename
2013+
different from the hour's initial filename.
2014+
</para>
19962015
</listitem>
19972016
</varlistentry>
19982017

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp