postgresql数据库的错误日志默认是打开的,如果需要开启或关闭则需要在postgresql.conf文件中进行配置。

通常情况下postgresql.conf位于程序安装的根目录下,以Mac操作系统为例,对应的配置文件路径为:

/Library/PostgreSQL/9.6/data/postgresql.conf

在该配置文件中,日志采集默认配置如下:

logging_collector = on # Enable capturing of stderr and csvlog
                       # into log files. Required to be on for
                       # csvlogs.
                       # (change requires restart)

对应该配置项下面,还有其他的关于日志的配置参数:

# These are only used if logging_collector is on:
#log_directory = 'pg_log'    # directory where log files are written, can be absolute or relative to PGDATA

#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 = off         # 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 = 10MB               # Automatic rotation of logfiles will
                                        # happen after that much log output.
                                        # 0 disables.

通过以上配置可以指定日志的输出格式,日志的输出文件等信息。



postgresql配置错误日志插图

关注公众号:程序新视界,一个让你软实力、硬技术同步提升的平台

除非注明,否则均为程序新视界原创文章,转载必须以链接形式标明本文链接

本文链接:https://choupangxia.com/2020/07/16/postgresql-error-log/