1
1
<!--
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 $
3
3
-->
4
4
5
5
<Chapter Id="runtime">
@@ -1929,16 +1929,16 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Win32
1929
1929
<term><varname>log_filename</varname> (<type>string</type>)</term>
1930
1930
<listitem>
1931
1931
<para>
1932
- When <varname>redirect_stderr</> is enabled, this option
1932
+ When <varname>redirect_stderr</varname > is enabled, this option
1933
1933
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
1936
1936
can be used to specify time-varying file names.
1937
- If no <literal>%</>-escapes are present,
1937
+ If no <literal>%</literal >-escapes are present,
1938
1938
<productname>PostgreSQL</productname> will
1939
1939
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 >
1942
1942
for a log starting at Sun Aug 29 19:02:33 2004 MST.
1943
1943
This option can only be set at server start or in the
1944
1944
<filename>postgresql.conf</filename> configuration file.
@@ -1950,7 +1950,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Win32
1950
1950
<term><varname>log_rotation_age</varname> (<type>integer</type>)</term>
1951
1951
<listitem>
1952
1952
<para>
1953
- When <varname>redirect_stderr</> is enabled, this option
1953
+ When <varname>redirect_stderr</varname > is enabled, this option
1954
1954
determines the maximum lifetime of an individual log file.
1955
1955
After this many minutes have elapsed, a new log file will
1956
1956
be created. Set to zero to disable time-based creation of
@@ -1965,7 +1965,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Win32
1965
1965
<term><varname>log_rotation_size</varname> (<type>integer</type>)</term>
1966
1966
<listitem>
1967
1967
<para>
1968
- When <varname>redirect_stderr</> is enabled, this option
1968
+ When <varname>redirect_stderr</varname > is enabled, this option
1969
1969
determines the maximum size of an individual log file.
1970
1970
After this many kilobytes have been emitted into a log file,
1971
1971
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
1980
1980
<term><varname>log_truncate_on_rotation</varname> (<type>boolean</type>)</term>
1981
1981
<listitem>
1982
1982
<para>
1983
- When <varname>redirect_stderr</> is enabled, this option will cause
1983
+ When <varname>redirect_stderr</varname > is enabled, this option will cause
1984
1984
<productname>PostgreSQL</productname> to truncate (overwrite),
1985
1985
rather than append to, any existing log file of the same name.
1986
1986
However, truncation will occur only when a new file is being opened
1987
1987
due to time-based rotation, not during server startup or size-based
1988
1988
rotation. When false, pre-existing files will be appended to in
1989
1989
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 >
1991
1991
would result in generating twenty-four hourly log files and then
1992
1992
cyclically overwriting them.
1993
1993
This option can only be set at server start or in the
1994
1994
<filename>postgresql.conf</filename> configuration file.
1995
1995
</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>
1996
2015
</listitem>
1997
2016
</varlistentry>
1998
2017
0 commit comments