1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-10 17:42:29 +03:00

Create a built-in log rotation program, so that we no longer have to

recommend that people go get Apache's rotatelogs program.  Additional
benefits are that configuration is done through GUC, rather than
externally, and that the postmaster can monitor the log rotator and
restart it after failure (though we certainly hope that won't happen
often).
Andreas Pflug, some rework by Tom Lane.
This commit is contained in:
Tom Lane
2004-08-05 23:32:13 +00:00
parent b4cd416ab0
commit bdf8ef6925
13 changed files with 1075 additions and 71 deletions

View File

@@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.225 2004/07/28 14:23:29 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.226 2004/08/05 23:32:12 tgl Exp $
*
*--------------------------------------------------------------------
*/
@@ -44,6 +44,7 @@
#include "parser/parse_expr.h"
#include "parser/parse_relation.h"
#include "postmaster/bgwriter.h"
#include "postmaster/syslogger.h"
#include "postmaster/postmaster.h"
#include "storage/bufmgr.h"
#include "storage/fd.h"
@@ -801,6 +802,26 @@ static struct config_bool ConfigureNamesBool[] =
&default_with_oids,
true, NULL, NULL
},
{
{"redirect_stderr", PGC_POSTMASTER, LOGGING_WHERE,
gettext_noop("Start a subprocess to capture stderr output into log files"),
NULL
},
&Redirect_stderr,
false, NULL, NULL
},
#ifdef WAL_DEBUG
{
{"wal_debug", PGC_SUSET, DEVELOPER_OPTIONS,
gettext_noop("Emit WAL-related debugging output."),
NULL,
GUC_NOT_IN_SAMPLE
},
&XLOG_DEBUG,
false, NULL, NULL
},
#endif
{
{"integer_datetimes", PGC_INTERNAL, COMPILE_OPTIONS,
@@ -816,18 +837,6 @@ static struct config_bool ConfigureNamesBool[] =
#endif
},
#ifdef WAL_DEBUG
{
{"wal_debug", PGC_SUSET, DEVELOPER_OPTIONS,
gettext_noop("Emit WAL-related debugging output."),
NULL,
GUC_NOT_IN_SAMPLE
},
&XLOG_DEBUG,
false, NULL, NULL
},
#endif
/* End-of-list marker */
{
{NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL
@@ -1245,6 +1254,24 @@ static struct config_int ConfigureNamesInt[] =
100, 1, 1000, NULL, NULL
},
{
{"log_rotation_age", PGC_SIGHUP, LOGGING_WHERE,
gettext_noop("Automatic logfile rotation will occur after N minutes"),
NULL
},
&Log_RotationAge,
24*60, 0, INT_MAX, NULL, NULL
},
{
{"log_rotation_size", PGC_SIGHUP, LOGGING_WHERE,
gettext_noop("Automatic logfile rotation will occur after N kilobytes"),
NULL
},
&Log_RotationSize,
10*1024, 0, INT_MAX, NULL, NULL
},
{
{"max_function_args", PGC_INTERNAL, COMPILE_OPTIONS,
gettext_noop("Shows the maximum number of function arguments"),
@@ -1634,6 +1661,23 @@ static struct config_string ConfigureNamesString[] =
&log_destination_string,
"stderr", assign_log_destination, NULL
},
{
{"log_directory", PGC_SIGHUP, LOGGING_WHERE,
gettext_noop("Sets the destination directory for logfiles."),
gettext_noop("May be specified as relative to the cluster directory "
"or as absolute path.")
},
&Log_directory,
"pg_log", NULL, NULL
},
{
{"log_filename_prefix", PGC_SIGHUP, LOGGING_WHERE,
gettext_noop("Prefix for file names created in the log_directory."),
NULL
},
&Log_filename_prefix,
"postgresql-", NULL, NULL
},
#ifdef HAVE_SYSLOG
{
@@ -5055,7 +5099,7 @@ assign_log_destination(const char *value, bool doit, GucSource source)
char *rawstring;
List *elemlist;
ListCell *l;
unsigned int newlogdest = 0;
int newlogdest = 0;
/* Need a modifiable copy of string */
rawstring = pstrdup(value);

View File

@@ -170,9 +170,23 @@
#log_destination = 'stderr' # Valid values are combinations of stderr,
# syslog and eventlog, depending on
# platform.
# This is relevant when logging to stderr:
#redirect_stderr = false # Enable capturing of stderr into log files.
# These are only relevant if redirect_stderr is true:
#log_directory = 'pg_log' # Directory where logfiles are written.
# May be specified absolute or relative to PGDATA
#log_filename_prefix = 'postgresql_' # Prefix for logfile names.
#log_rotation_age = 1440 # Automatic rotation of logfiles will happen after
# so many minutes. 0 to disable.
#log_rotation_size = 10240 # Automatic rotation of logfiles will happen after
# so many kilobytes of log output. 0 to disable.
# These are relevant when logging to syslog:
#syslog_facility = 'LOCAL0'
#syslog_ident = 'postgres'
# - When to Log -
#client_min_messages = notice # Values, in order of decreasing detail: