Updated on 2024-05-07 GMT+08:00

Logging Destination

log_destination

Parameter description: GaussDB supports several methods of logging server messages. Set this parameter to a list of desired log destinations separated by commas. (For example, log_destination="stderr,csvlog")

This parameter is a SIGHUP parameter. Set it based on instructions provided in Table 1.

Value range: a string.

The valid values are stderr, csvlog, and syslog.

  • stderr indicates that logs are printed to the screen.
  • csvlog indicates that logs are output in comma-separated value (CSV) format. The prerequisite for generating logs in CSV format is that logging_collector must be set to on. For details, see Using CSV Log Output.
  • syslog indicates that logs are recorded using the syslog of the OS. GaussDB can record logs using syslog from LOCAL0 to LOCAL7. For details, see syslog_facility. To record logs using syslog, add the following information to syslog daemon's configuration file:
    1
    local0.*  /var/log/postgresql
    

Default value: stderr

logging_collector

Parameter description: Specifies whether to enable the logger process to collect logs. This process captures log messages sent to stderr or csvlog and redirects them into log files.

This method is more effective than recording logs to syslog because some types of messages cannot be displayed in syslog output, such as messages indicating the loading failures of dynamic link libraries and error messages generated by scripts (for example, archive_command).

This parameter is a POSTMASTER parameter. Set it based on instructions provided in Table 1.

It is possible to log to stderr without using the logging collector and the log messages will go to where the server's stderr is directed. However, this method is only suitable for low log volumes due to difficulties in rotating log files.

Value range: Boolean

  • on indicates that the log collection is enabled.
  • off indicates that the log collection is disabled.

Default value: on

log_directory

Parameter description: Specifies the directory for storing log files when logging_collector is set to on. The value can be an absolute path, or relative to the data directory. The log_directory parameter can be dynamically modified using the gs_guc reload command. Only the sysadmin user can access this parameter.

This parameter is a SIGHUP parameter. Set it based on instructions provided in Table 1.

  • If this parameter is set to an invalid path, the cluster cannot be started.
  • If you modify the log_directory parameter using the gs_guc reload command, and the specified path is valid, the log files are output to this new path. If the specified path is invalid, the log files are output to the valid path set last time and the database operation is not affected. The invalid value is still written into the configuration file.
  • In the sandbox environment, the path cannot contain /var/chroot. For example, if the absolute path of log is /var/chroot/var/lib/log/Ruby/pg_log/cn_log, you only need to set the path to /var/lib/log/Ruby/pg_log/cn_log.
  • Valid path: Users have read and write permissions on the path.
  • Invalid path: Users do not have read or write permissions on an invalid path.

Value range: a string

Default value: specified during installation

log_filename

Parameter description: Specifies the names of generated log files when logging_collector is set to on. The value is treated as a strftime pattern, so %-escapes can be used to specify time-varying file names. Only the sysadmin user can access this parameter.

This parameter is a SIGHUP parameter. Set it based on instructions provided in Table 1.

  • You are advised to use %-escapes to specify the log file names for efficient management of log files.
  • If log_destination is set to csvlog, log files are output in CSV format with timestamped names, for example, server_log.1093827753.csv.

Value range: a string

Default value: postgresql-%Y-%m-%d_%H%M%S.log

log_file_mode

Parameter description: Specifies the permissions of log files when logging_collector is set to on. This parameter is invalid on Windows. The parameter value is usually a number in the format acceptable to the chmod and umask system calls.

This parameter is a SIGHUP parameter. Set it based on instructions provided in Table 1.

  • Before setting this parameter, set log_directory to store the logs to a directory other than the data directory.
  • Do not make the log files world-readable because they might contain sensitive data.

Value range: an octal integer ranging from 0000 to 0777 (that is, 0 to 511 in the decimal format)

  • 0600 indicates that log files are readable and writable only to the server administrator.
  • 0640 indicates that log files are readable and writable to members of the administrator's group.

Default value: 0600

log_truncate_on_rotation

Parameter description: Specifies the writing mode of the log files when logging_collector is set to on.

This parameter is a SIGHUP parameter. Set it based on instructions provided in Table 1.

A setting example is as follows:

Assume that you want logs to be kept for 7 days, a log file generated each day to be named server_log.Mon on Monday, server_log.Tue on Tuesday, and so forth, and this week's log files to be overwritten by next week's log files. Then you can set log_filename to server_log.%a, log_truncate_on_rotation to on, and log_rotation_age to 1440 (indicating that the valid duration of the log file is 24 hours).

Value range: Boolean

  • on indicates that GaussDB overwrites the existing log files of the same name on the server.
  • off indicates that GaussDB appends the logging messages to the existing log files of the same name on the server.

Default value: off

log_rotation_age

Parameter description: Specifies the interval for creating a log file when logging_collector is set to on. If the duration from the time when the last log file was created to the current time is greater than the value of log_rotation_age, a new log file will be generated.

This parameter is a SIGHUP parameter. Set it based on instructions provided in Table 1.

Value range: an integer ranging from 0 to 35791394. The unit is min. 0 indicates that the time-based creation of new log files is disabled.

Default value: 1d (1440 min)

log_rotation_size

Parameter description: Specifies the maximum size of a server log file when logging_collector is set to on. If the total size of messages in a log file exceeds the specified value, a log file will be generated.

This parameter is a SIGHUP parameter. Set it based on instructions provided in Table 1.

Value range: an integer ranging from 0 to 2097151. The unit is KB.

0 indicates that the capacity-based creation of new log files is disabled.

Default value: 20 MB

syslog_facility

Parameter description: Specifies the syslog facility to be used when log_destination is set to syslog.

This parameter is a SIGHUP parameter. Set it based on instructions provided in Table 1.

Value range: enumerated values. Valid values are local0, local1, local2, local3, local4, local5, local6, and local7.

Default value: local0

syslog_ident

Parameter description: Specifies the identifier of GaussDB messages in syslog logs when log_destination is set to syslog.

This parameter is a SIGHUP parameter. Set it based on instructions provided in Table 1.

Value range: a string

Default value: postgres

event_source

Parameter description: Specifies the identifier of GaussDB messages in logs when log_destination is set to eventlog.

This parameter is a POSTMASTER parameter. Set it based on instructions provided in Table 1.

Value range: a string

Default value: PostgreSQL