I’m using Postgres 9.5 on Ubuntu 14.04. I have these settings set in my /etc/postgresql/9.5/main/postgresql.conf file

log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern,
                                        # can include strftime() escapes
#log_file_mode = 0600                   # creation mode for log files,
                                        # begin with 0 to use octal notation
log_truncate_on_rotation = on           # If on, an existing log file with the
                                        # same name as the new log file will be
                                        # truncated rather than appended to.
                                        # But such truncation only occurs on
                                        # time-driven rotation, not on restarts
                                        # or size-driven rotation.  Default is
                                        # off, meaning append to existing files
                                        # in all cases.
#log_rotation_age = 1d                  # Automatic rotation of logfiles will
                                        # happen after that time.  0 disables.
log_rotation_size = 50MB                # Automatic rotation of logfiles will
                                        # happen after that much log output.
                                        # 0 disables.

Although I have restarted my server using the

sudo /etc/init.d/postgresql restart

command, when I run some transaction and check my logs, the log files are not respecting my files names …

myuser@mymachine:~$ ls -al /var/log/postgresql/
total 1912144
drwxrwxr-t  2 root     postgres       4096 Dec 31 14:27 .
drwxrwxr-x 14 root     syslog         4096 Dec 31 06:55 ..
-rw-r-----  1 postgres postgres 1957826560 Dec 31 14:30 postgresql-9.5-main.log
-rw-r-----  1 postgres postgres     194785 Dec 26 06:46 postgresql-9.5-main.log.1

Why is Postgres not respecting the filename convention I specified in the configuration file and how do I get it to?


You need to edit the values for logging_collector and log_directory so that it knows you want to manage the logs and where they should go.


Look at the section for log_filename.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.