Updated on 2025-05-29 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 can be set to "stderr,csvlog".)

Parameter type: string.

Unit: none

Value range: "stderr", "csvlog", "syslog", and "eventlog".

  • "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/omm
    
  • "eventlog" indicates that logs are recorded using the event log component. This function is supported only in the Windows OS.

Default value: "stderr"

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

Setting suggestion: Retain the default value.

Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.

logging_collector

Parameter description: Specifies whether to enable the logger thread to collect logs. This thread 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.

It is possible to log to stderr without using the parameter 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.

Parameter type: Boolean.

Unit: none

Value range:

  • on: The log collection is enabled.
  • off: The log collection is disabled.

Default value: on

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

Setting suggestion: Retain the default value.

Risks and impacts of improper settings: When this parameter is disabled, CSV logs cannot be used to record logs.

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.

  • If log_directory in the configuration file is set to an invalid path, the database 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 of log_directory 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/gs_log/cn_log, you only need to set the path to /var/lib/log/Ruby/gs_log/cn_log.
  • Valid path: Users have read and write permissions on the path.
  • Invalid path: Users do not have read or write permission on the path.

Parameter type: string.

Unit: none

Value range: a string.

Default value: specified during installation.

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

Setting suggestion: Retain the default value.

Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.

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.

  • 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.

Parameter type: string.

Unit: none

Value range: a string.

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

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

Setting suggestion: Retain the default value.

Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.

log_file_mode

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

  • 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.

Parameter type: integer

Unit: none

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

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

Setting suggestion: Retain the default value.

Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.

log_truncate_on_rotation

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

Parameter type: Boolean.

Unit: none

Value range:

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

Default value: off

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

Setting suggestion: Retain the default value.

Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.

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.

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.

Setting method: Set log_filename to server_log.%a, log_truncate_on_rotation to on, and log_rotation_age to 1440.

Parameter type: integer

Unit: minute

Value Range: 0 to 35791394. 0 indicates that the time-based creation of new log files is disabled.

Default value: 1440

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

Setting suggestion: Retain the default value.

Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.

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 maximum size, a log file will be generated.

Parameter type: integer

Unit: KB

Value Range: 0 to 2097151. 0 indicates that the capacity-based creation of new log files is disabled.

Default value: 20480 (20 MB)

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

Setting suggestion: Retain the default value.

Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.

syslog_facility

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

Value type: enumerated type

Unit: none

Value range: local0, local1, local2, local3, local4, local5, local6, and local7.

Default value: local0

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

Setting suggestion: Retain the default value.

Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.

syslog_ident

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

Parameter type: string.

Unit: none

Value range: a string.

Default value: "postgres"

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

Setting suggestion: Retain the default value.

Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.

event_source

Parameter description: This parameter takes effect only in a Windows environment. It specifies the identifier of GaussDB messages in logs when log_destination is set to eventlog.

Parameter type: string.

Unit: none

Value range: a string.

Default value: "PostgreSQL"

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

Setting suggestion: Retain the default value.

Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.