为什么 Postgres 不遵守“log_filename”规定的我的日志文件名约定?

Dav*_*ave 5 postgresql configuration disk-space log files

我在 Ubuntu 14.04 上使用 Postgres 9.5。我在 /etc/postgresql/9.5/main/postgresql.conf 文件中设置了这些设置

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.
Run Code Online (Sandbox Code Playgroud)

虽然我已经使用

sudo /etc/init.d/postgresql restart
Run Code Online (Sandbox Code Playgroud)

命令,当我运行一些事务并检查我的日志时,日志文件不尊重我的文件名......

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
Run Code Online (Sandbox Code Playgroud)

为什么 Postgres 不遵守我在配置文件中指定的文件名约定,我该如何实现?

小智 1

logging_collector您需要编辑和的值,log_directory以便它知道您想要管理日志以及它们应该放在哪里。

https://www.postgresql.org/docs/9.5/static/runtime-config-logging.html

查看 的部分log_filename