Log directories

These are the log directories in Postgres:


The $PGDATA/pg_log log is the default location for the database activity logs. This log include error messages, query logging, and startup/shutdown messages. You should first look for information in this log when Postgres does not start. Many Linux distributions and other packaging systems relocate this log directory to another place, for example, /var/log/postgresql.

You can freely delete, rename, compress, and move files in pg_log without penalty, as long as the enterprisedb user still has rights to write to the directory. If pg_log is filled with several large files, change the settings in postgresql.conf to decrease the logged items.


The $PGDATA/pg_xlog log is the Postgres transaction log. This set of binary log files contain images of the data from recent transactions. These logs are also used for binary replication. For an example of binary log name, '00000001000000000000008E'.

If replication, archiving, or PITR is failing, this directory can be filled with gigabytes of logs that the database server is saves when archiving resumes. This can cause you to run out of disk space.

Unlike pg_log, you can not freely delete, move, or compress files in this directory. And, if you move the directory, you must symlinking it back to its original location. Deleting pg_xlog files may result in irrecoverable database corruption.

In case pg_xlog reach 100GB of files, and the database does not start, and you have already disabled archiving/replication and cleared the disk space, then do these:

Move files

  1. Move files from pg_xlog to a backup disk or shared network drive, do not delete the files.
  2. Move only enough of a few old files to allow Postgres to start again.


The $PGDATA/pg_clog log contains a log of transaction metadata. This log tells Postgres which transactions have completed and which are not. The clog is small and never has any reason to over fill. You do not need to modify this log.

In case you delete files from pg_clog, you must also delete the entire database directory. There is no recovery procedure from a missing clog.

Note that this means that if you back up the files in a $PGDATA directory, you must include the pg_clog and pg_xlog logs as well. Or, your backup becomes not usable.