1. Check the file configuration and see where the log file is
logging_collector = on log_directory = 'pg_log' log_filename = 'postgresql-%' log_truncate_on_rotation = o
2. Log classification
pg_log (database run log) content is readable. It is closed by default. You need to set parameters to start.
pg_xlog (WAL log, i.e. redo log) Content is generally not readable Forced to open
pg_clog (transaction commit log, recording transaction metadata) Content is generally not readable Forced to open
3. The role of each log
(1) pg_log This log generally records the status of the server and DB, such as various Error information, slow query of SQL, database startup and shutdown information, alarm information such as checkpoint too frequently, etc. The log has .csv format and .log.
It is recommended to use the .csv format because it will generally be automatically cut by size and time. After all, viewing a huge log file is much harder than viewing multiple logs for different time periods.
pg_log can be cleaned, deleted, compressed, packaged or transferred, and does not affect the normal operation of DB. When we encounter that DB cannot start or the change parameters does not take effect, the first thing that comes to mind is to view this log.
(2) pg_xlog This log is the WAL information of Postgresql, that is, some transaction log information (transaction log). The default single size is 16M. When installing the source code, it can be changed (./configure --with-wal-segsize=target_value parameter, which can be set). These logs will be used in time rollback recovery (PITR), stream replication (Replication Stream) and archive. These logs are very important and record various transaction information in the database. Such log files must not be deleted or moved at will, otherwise your database will be at risk of being unable to recover.
Supplement: The file in the xlog directory of postgresql log report cannot be found
Force reset transaction log through pg's own command, and enter the bin directory of pg
enterpg_resetxlog -f %pgdata%
Where -f is mandatory, %pgdata% needs to go to the data directory according to the on-site environment
After recovery, all user passwords in the database will be reset, configured to log in to pg without password, and modify the password
The above is personal experience. I hope you can give you a reference and I hope you can support me more. If there are any mistakes or no complete considerations, I would like to give you advice.