类型: string
默认: stderr
上下文: sighup
重新开始: false

PostgreSQL支持多种方法来记录服务器消息,包括stderr、csvlog和syslog。在 Windows 上还支持eventlog。设置这个参数为一个由想要的日志目的地的列表,之间用逗号分隔。默认值是只记录到stderr。这个参数只能在postgresql.conf文件中或在服务器命令行上设置。

如果csvlog被包括在log_destination中,日志项会以逗号分隔值 (CSV)格式被输出,这样可以很方便地把日志载入到程序中。详见runtime-config-logging-csvlog。要产生 CSV 格式的日志输出,必须启用logging_collector。

当包括有stderr或csvlog时,会创建文件current_logfiles来记录当前正在被日志收集器使用的日志文件的位置以及相关的日志目的地。这提供了一种查找实例当前使用的日志的便利手段。这里是该文件内容的一个例子:stderr log/postgresql.logcsvlog log/postgresql.csv 当由于轮转效应创建一个新的日志文件时以及log_destination被重载时,current_logfiles文件会被重建。当log_destination中不包括stderr和csvlog时以及当日志收集器被禁用时,这个文件会被删除。

在大多数 Unix 系统上,你将需要修改系统的syslog守护进程的配置来使用log_destination的syslog选项。PostgreSQL可以在syslog设备LOCAL0到LOCAL7中记录(见syslog_facility),但是大部分平台上的默认syslog配置会丢弃所有这种消息。你将需要增加这样的内容:local0.* /var/log/postgresql 到syslog守护进程的配置文件来让它工作。

在 Windows 上,当你使用log_destination的eventlog选项时,你应该在操作系统中注册一个事件源极其库,这样 Windows 事件查看器能够清楚地显示事件日志消息。详见event-log-registration。

建议 [EN]

Your choice of log destination depends on your system administration plans and the status of your server. “syslog” or “eventlog” (Windows) are good choices for most development servers, because they can support centralized log monitors. For development and testing, however, “csvlog” is probably the most useful, as it allows you to run queries against the log contents.

条评论