Logging
Greengage DB can log various events, including DBMS startup and shutdown, segment database failures, connection attempts, data manipulation events, and more. These logs can be monitored to help detect potential security threats. For example, you can track who created new user accounts and when they were created.
This topic describes how to configure logging to record information with varying levels of detail and how to view logs that match specific criteria.
Overview
Log files location
Logs are stored in a custom format, which uses comma-separated values (CSV).
You can use the gplogfilter utility to view and filter logs.
The coordinator and segment hosts store their own set of log files in the following locations:
-
Coordinator host
On the coordinator host, logs are stored in the $COORDINATOR_DATA_DIRECTORY/log directory. By default, the
gplogfilterutility uses this location if an input log file is not supplied. -
Segment hosts
On segment hosts, logs are stored in the /<data_dir>/primary/gpseg<N>/log and /<data_dir>/mirror/gpseg<N>/log directories. For example, on the
sdw1segment host initialized in the Initialize DBMS topic, logs are stored in the following locations:-
primary segments: /data1/primary/gpseg0/log, /data1/primary/gpseg1/log;
-
mirror segments: /data1/mirror/gpseg2/log, /data1/mirror/gpseg3/log.
-
By default, logs created by administrative utilities such as gpinitsystem, gpstart, and gpconfig are stored in the ~/gpAdminLogs directory of the Greengage DB administrative user.
Examples of log entries
Below are a few examples of log entries that are shown in a format used by gplogfilter:
-
Indicates that the coordinator instance (
seg-1) has started and ready to accept client connections:2026-04-22 13:50:03.112519 UTC|||p6097|th736475584||||0|||seg-1|||||LOG: |00000|database system is ready to accept connections|PostgreSQL 12.22 (Greengage Database 7.4.1 build dev) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0, 64-bit compiled on Apr 21 2026 14:51:47||||||0||postmaster.c|3548|
-
Shows that the
gpadminuser connected locally using a Unix domain socket and created thecrmdatabase:2026-04-22 13:55:04.810736 UTC|gpadmin|postgres|p6353|th736475584|[local]||2026-04-22 13:54:59 UTC|0|con22|cmd1|seg-1||||sx1|LOG: |00000|statement: CREATE DATABASE crm;|||||||0||postgres.c|1691|
-
Shows that the
aliceuser connected to thecrmdatabase successfully from a remote host with the192.168.10.55IP address:2026-04-22 13:59:47.365002 UTC|alice|crm|p6478|th736475584|192.168.10.55|44588|2026-04-22 13:59:47 UTC|0|con42||seg-1||||sx1|LOG: |00000|connection authorized: user=alice database=crm application_name=psql|||||||0||postinit.c|351|
Logging configuration parameters
Logging configuration is controlled by server configuration parameters that start with log_ or gp_log_.
You can modify the default parameter values as described in Configure logging.
The following sections group important logging configuration parameters into related categories.
Logging levels and verbosity
- log_min_messages
-
Controls which message levels are written to the server log. Possible values include
INFO,WARNING,FATAL, and more. - log_error_verbosity
-
Controls the amount of detail written in the server log for each log message. Possible values include
DEFAULT,TERSE, andVERBOSE. - log_statement
-
Controls which SQL statements are logged. For example, you can enable logging of DDL statements only. Possible values include
NONE,DDL,MOD, andALL.
Client connections
- log_connections/log_disconnections
-
Control whether to log client connections and terminations of client sessions.
- log_hostname
-
Sets whether to include a client’s host name in connection log messages. Depending on your host name resolution configuration, enabling this option may introduce a noticeable performance overhead.
Performance statistics
- log_statement_stats
-
Writes the total performance statistics of the query parser, planner, and executor to the server log for each SQL query.
- log_parser_stats
-
Writes performance statistics of the query parser to the server log for each SQL query.
- log_planner_stats
-
Writes performance statistics of the Postgres-based planner to the server log for each SQL query.
Log file rotation
- log_rotation_size
-
Sets the maximum size of a log file before it rotates. When the file reaches this size, it closes, and a new log file is created.
- log_rotation_age
-
Specifies the maximum age of a log file before it is rotated. Once the specified time has passed since the log file was created, a new log file is generated. By default, log files are rotated every 24 hours.
Configure logging
To change a configuration parameter related to logging, use the gpconfig -c command.
Below are a few examples of changing the default values for some logging parameters:
-
Enable logging of client connections on the coordinator instance:
$ gpconfig -c log_connections -v 'on' --coordinatoronly -
Configure the coordinator instance to log only DDL statements (such as
CREATE,ALTER, orDROP):$ gpconfig -c log_statement -v 'ddl' --coordinatoronly -
Set the log file rotation size to 256 MB across the entire Greengage DB cluster:
$ gpconfig -c log_rotation_size -v 256MB
To apply the changes, either reload the configuration or restart the cluster using gpstop, depending on the parameter.
For example, reloading the configuration is enough for log_connections and log_statement, while changing gp_log_format requires a full cluster restart:
$ gpstop -u
$ gpstop -ra
View logs
To view logs, use the gplogfilter utility.
By default, this utility searches through the Greengage DB coordinator log files in a location defined by the COORDINATOR_DATA_DIRECTORY environment variable.
The gp_toolkit administrative schema provides a set of gp_log_* views that allow you to execute SQL queries against the server logs.
Filter logs
The examples below show how to filter coordinator log files.
-
Show
ERROR,FATAL, orPANIClog entries:$ gplogfilter --trouble -
Show the last 10 log entries:
$ gplogfilter --tail 10 -
Show events that happened in the specified time range:
$ gplogfilter --begin '2025-02-28 07:20' --end '2025-02-28 07:30' -
Show all log messages from the last 10 minutes relative to the current time:
$ gplogfilter --duration :10 -
Select only specific columns:
$ gplogfilter --columns '2,3,19' -
Search for log entries that contain the exact string:
$ gplogfilter --find 'connection authorized' -
Search for log entries that match the specified regular expression:
$ gplogfilter --match 'connection authorized:.*database=crm'
Input and output options
The examples below demonstrate how to write the gplogfilter output to files and read the specified log files.
-
Write the output to the coordinatorlog.out file instead of standard output (stdout):
$ gplogfilter --end '2025-02-28 07:30' --out coordinatorlog.out -
Compress the output file using the specified compression level:
$ gplogfilter --end '2025-02-28 07:30' --out coordinatorlog.out --zip=7 -
Read the coordinatorlog.out log file:
$ gplogfilter coordinatorlog.out -
Read the compressed log file:
$ gplogfilter coordinatorlog.out.gz --unzip
View logs on segments
To read log files on the segment hosts, use the gpssh utility.
The command below:
-
runs
gplogfilteron all segment hosts listed in the hostfile_segment_hosts file; -
filters the logs to show only
ERROR,FATAL, orPANICmessages; -
writes the output to the seglog.out file.
$ gpssh -f hostfile_segment_hosts -e " \
source /usr/local/gpdb/greengage_path.sh && \
gplogfilter /data1/*/*/log/gpdb*.csv \
--trouble \
" > seglog.out