PostgreSQL Database configuration csv format log output
The following is an introduction to the Setup method for the CSV format log (a more verbose log output in PG) in the PostgreSQL database.
1. go to the $PGDATA directory (PG installation directory, depending on the specific case name) to locate the configuration file postgresql.conf
2. turn on the csvlog output function :
#开启csvlog输出功能 (default is OFF)
Logging_collector = On
Note: you will need to restart the database after modifying the Logging_collector (you can also continue with the configuration after all configuration has been completed and then restarted)
#设置csv日志输出目录 ($PGDATA directory, if the directory does not exist, the system will be automatically created )
log_directory = ' Pg_log '
#设置输出的日志格式 (type), the log types in PG are stderr,csvlog,syslog, and EventLog, which are set to Csvlog in this example
#该选项默认为stderr Types
log_destination = ' Csvlog '
All configurations are over, and if you do not restart the data after configuring Logging_collector , reboot the database to be OK.
3. Description of the log_statement configuration :
Log_statement defaults to None, indicating that only system information (such as database startup, database connection, database shutdown, and so on) is logged.
Other optional configurations are DDL, mod and all. Where "DDL" represents the database definition language, including Drop,create,alter,grant,revoke, truncate and other statement execution records, "mod" indicates that the record database executes update UPDATE statement records, "all" Indicates that all execution records are logged. It is not recommended to set it to all easily, otherwise the database will generate a lot of logs and occupy more hard disk space.