{"Entry":{"collection":"guc","key":"log_destination","name":"log_destination","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Reporting and Logging / Where to Log","category_zh":"","changed_in":["15"],"changes":[{"documentation_changed":false,"fields":{},"from":"7.4","status":"added","to":"8.0"},{"documentation_changed":true,"fields":{},"from":"8.0","status":"changed","to":"8.1"},{"documentation_changed":true,"fields":{},"from":"8.1","status":"changed","to":"8.2"},{"documentation_changed":true,"fields":{},"from":"8.2","status":"changed","to":"8.3"},{"documentation_changed":true,"fields":{},"from":"8.4","status":"changed","to":"9.0"},{"documentation_changed":true,"fields":{},"from":"9.0","status":"changed","to":"9.1"},{"documentation_changed":true,"fields":{},"from":"9.1","status":"changed","to":"9.2"},{"documentation_changed":true,"fields":{},"from":"9.5","status":"changed","to":"9.6"},{"documentation_changed":true,"fields":{},"from":"9.6","status":"changed","to":"10"},{"documentation_changed":true,"fields":{},"from":"11","status":"changed","to":"12"},{"documentation_changed":true,"fields":{},"from":"13","status":"changed","to":"14"},{"documentation_changed":true,"fields":{"extra_desc":{"from":"Valid values are combinations of \"stderr\", \"syslog\", \"csvlog\", and \"eventlog\", depending on the platform.","to":"Valid values are combinations of \"stderr\", \"syslog\", \"csvlog\", \"jsonlog\", and \"eventlog\", depending on the platform."}},"from":"14","status":"changed","to":"15"},{"documentation_changed":true,"fields":{},"from":"16","status":"changed","to":"17"},{"documentation_changed":true,"fields":{},"from":"17","status":"changed","to":"18"}],"content_hash":"745c0b36faaf3006e61cf0653426e52bd4a1ea6b660f8ad7794122a5cd1fbd07","context":"","default_changed_in":[],"default_history":[{"from":"9.0","to":"19","value":"stderr"}],"editorial":{"advice":{"olap":"Size the log_destination path for bursty analytical output and verify that rotation or downstream ingestion cannot stall database processes.","oltp":"Set log_destination as part of one end-to-end logging design. Validate collector behavior, rotation, ownership, shipping, retention, and recovery from a full destination.","small":"Use a bounded, easily rotated log_destination configuration and monitor free space; a small node should not retain redundant formats or unlimited files."},"mechanism":["log_destination sets the destination for server log output. Valid values are combinations of \"stderr\", \"syslog\", \"csvlog\", \"jsonlog\", and \"eventlog\", depending on the platform. Several destinations can be active at once; csvlog and jsonlog require logging_collector, while stderr, syslog, and Windows eventlog follow different transport paths.","log_destination is a SIGHUP-context setting: a configuration reload activates the new server value without a restart; subsequent operations that consult it use the refreshed value.","The active path is composed from log_destination, logging_collector or syslog/eventlog, file naming and permissions, rotation triggers, and external shipping or retention."],"pitfalls":["Editing log_destination without reloading configuration and verifying the effective value and subsequent behavior.","Combining incompatible destination, collector, filename, and rotation assumptions and then losing or overwriting logs.","Failing to monitor a full or unwritable log target, which can block logging or database activity depending on the path.","Changing log_destination globally without a rollback plan and a client or operational compatibility test."],"references":[{"title":"PostgreSQL 19 Beta 4: log_destination","url":"https://www.postgresql.org/docs/19/runtime-config-logging.html#GUC-LOG-DESTINATION"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["logging_collector","log_directory","log_filename","log_rotation_age","log_rotation_size"],"summary":"log_destination is the PostgreSQL setting that defines the destination for server log output."},"enumvals":[],"first_version":"8.0","group":"Reporting and Logging","group_slug":"logging","imported_at":"2026-09-30T00:40:57.297061+08:00","intro_commit":{},"key":"log_destination","last_version":"20","max_val":"","min_val":"","name":"log_destination","position":221,"present_in":["8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"short_desc":"PostgreSQL supports several methods for logging server messages, including stderr, csvlog, jsonlog, and syslog.","short_desc_zh":"","source_rev":"english-manuals:06312c0c4bc6ca061dccd3da987d5b1f13ae10b9268f240d0263cb26723dfb94","unit":"","vartype":"string"}},"Definition":{"Collection":"guc","Key":"log_destination","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"log_destination","SourceRevision":"english-manuals:06312c0c4bc6ca061dccd3da987d5b1f13ae10b9268f240d0263cb26723dfb94","Facts":{"boot_val":"stderr","category":"Reporting and Logging / Where to Log","context":"sighup","description":"PostgreSQL supports several methods for logging server messages, including stderr, csvlog, jsonlog, and syslog. On Windows, eventlog is also supported. Set this parameter to a list of desired log destinations separated by commas. The default is to log to stderr only. This parameter can only be set in the postgresql.conf file or on the server command line. If csvlog is included in log_destination, log entries are output in “comma-separated value” (CSV) format, which is convenient for loading logs into programs. See Section 19.8.4 for details. logging_collector must be enabled to generate CSV-format log output. If jsonlog is included in log_destination, log entries are output in JSON format, which is convenient for loading logs into programs. See Section 19.8.5 for details. logging_collector must be enabled to generate JSON-format log output. When either stderr, csvlog or jsonlog are included, the file current_logfiles is created to record the location of the log file(s) currently in use by the logging collector and the associated logging destination. This provides a convenient way to find the logs currently in use by the instance. Here is an example of this file's content: stderr log/postgresql.log csvlog log/postgresql.csv jsonlog log/postgresql.json current_logfiles is recreated when a new log file is created as an effect of rotation, and when log_destination is reloaded. It is removed when none of stderr, csvlog or jsonlog are included in log_destination, and when the logging collector is disabled. Note On most Unix systems, you will need to alter the configuration of your system's syslog daemon in order to make use of the syslog option for log_destination. PostgreSQL can log to syslog facilities LOCAL0 through LOCAL7 (see syslog_facility), but the default syslog configuration on most platforms will discard all such messages. You will need to add something like: local0.* /var/log/postgresql to the syslog daemon's configuration file to make it work. On Windows, when you use the eventlog option for log_destination, you should register an event source and its library with the operating system so that the Windows Event Viewer can display event log messages cleanly. See Section 18.12 for details.","doc":{"anchor":"GUC-LOG-DESTINATION","file":"runtime-config-logging.html","lang":"en","sha256":"93c48c522a72fca19705c4c91a71e951eae653662008eee2e4a9a74a11127fde","slug":"18"},"documented":true,"enumvals":null,"extra_desc":"Valid values are combinations of \"stderr\", \"syslog\", \"csvlog\", \"jsonlog\", and \"eventlog\", depending on the platform.","lang":"en","max_val":null,"metadata_version":"18","min_val":null,"name":"log_destination","short_desc":"Sets the destination for server log output.","source":"pg-settings-source-snapshot","unit":null,"vartype":"string"},"ManualEvidence":{"doc":{"anchor":"GUC-LOG-DESTINATION","file":"runtime-config-logging.html","lang":"en","sha256":"93c48c522a72fca19705c4c91a71e951eae653662008eee2e4a9a74a11127fde","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"log_destination","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"log_destination","Summary":"","BodyHTML":"\u003cp\u003e\u003cspan\u003ePostgreSQL\u003c/span\u003e支持多种记录服务器消息的方法，包括 \u003cspan\u003estderr\u003c/span\u003e，\u003cspan\u003ecsvlog\u003c/span\u003e，\u003cspan\u003ejsonlog\u003c/span\u003e和 \u003cspan\u003esyslog\u003c/span\u003e。在Windows上，\u003cspan\u003eeventlog\u003c/span\u003e也受支持。将此参数设置为以逗号分隔的所需日志目的地列表。默认情况下仅记录到 \u003cspan\u003estderr\u003c/span\u003e。此参数只能在\u003ccode\u003epostgresql.conf\u003c/code\u003e 文件或服务器命令行中设置。\u003c/p\u003e\u003cp\u003e如果\u003cspan\u003ecsvlog\u003c/span\u003e被包括在\u003ccode\u003elog_destination\u003c/code\u003e中，日志项会以\u003cspan\u003e“\u003cspan\u003e逗号分隔值\u003c/span\u003e”\u003c/span\u003e（CSV）格式被输出，这样可以很方便地把日志载入到程序中。详见\u003ca href=\"/docs/18/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-CSVLOG\" rel=\"nofollow\"\u003e第 19.8.4 节\u003c/a\u003e。要产生 CSV 格式的日志输出，必须启用\u003ca href=\"/docs/18/runtime-config-logging.html#GUC-LOGGING-COLLECTOR\" rel=\"nofollow\"\u003elogging_collector\u003c/a\u003e。\u003c/p\u003e\u003cp\u003e如果\u003cspan\u003ejsonlog\u003c/span\u003e包含在\u003ccode\u003elog_destination\u003c/code\u003e中，日志条目将以JSON格式输出，这对将日志加载到程序中很方便。有关详细信息，请参见\u003ca href=\"/docs/18/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-JSONLOG\" rel=\"nofollow\"\u003e第 19.8.5 节\u003c/a\u003e。必须启用\u003ca href=\"/docs/18/runtime-config-logging.html#GUC-LOGGING-COLLECTOR\" rel=\"nofollow\"\u003elogging_collector\u003c/a\u003e才能生成JSON格式的日志输出。\u003c/p\u003e\u003cp\u003e当包含\u003cspan\u003estderr\u003c/span\u003e、\u003cspan\u003ecsvlog\u003c/span\u003e或\u003cspan\u003ejsonlog\u003c/span\u003e时，文件\u003ccode\u003ecurrent_logfiles\u003c/code\u003e会被创建，记录日志收集器当前使用的日志文件位置和相关的日志目的地。这提供了一种方便的方式来查找实例当前使用的日志。以下是该文件内容的示例：\u003c/p\u003e\u003cpre\u003estderr log/postgresql.log\ncsvlog log/postgresql.csv\njsonlog log/postgresql.json\n\u003c/pre\u003e\u003cp\u003e当由于轮换而创建新的日志文件时，以及重新加载\u003ccode\u003elog_destination\u003c/code\u003e时，\u003ccode\u003ecurrent_logfiles\u003c/code\u003e会被重新创建。当\u003ccode\u003elog_destination\u003c/code\u003e中不包含\u003cspan\u003estderr\u003c/span\u003e、\u003cspan\u003ecsvlog\u003c/span\u003e或\u003cspan\u003ejsonlog\u003c/span\u003e，或者日志收集器被禁用时，它会被移除。\u003c/p\u003e\u003cdiv\u003e\n注意\u003cp\u003e在大多数 Unix 系统上，你将需要修改系统的\u003cspan\u003esyslog\u003c/span\u003e守护进程的配置来使用\u003ccode\u003elog_destination\u003c/code\u003e的\u003cspan\u003esyslog\u003c/span\u003e选项。\u003cspan\u003ePostgreSQL\u003c/span\u003e可以在\u003cspan\u003esyslog\u003c/span\u003e设施\u003ccode\u003eLOCAL0\u003c/code\u003e到\u003ccode\u003eLOCAL7\u003c/code\u003e中记录（见\u003ca href=\"/docs/18/runtime-config-logging.html#GUC-SYSLOG-FACILITY\" rel=\"nofollow\"\u003esyslog_facility\u003c/a\u003e），但是大部分平台上的默认\u003cspan\u003esyslog\u003c/span\u003e配置会丢弃所有这种消息。你需要在\u003cspan\u003esyslog\u003c/span\u003e守护进程的配置文件中增加类似以下的内容，使其生效：\u003c/p\u003e\u003cpre\u003elocal0.*    /var/log/postgresql\n\u003c/pre\u003e\u003cp\u003e在 Windows 上，当你使用\u003ccode\u003elog_destination\u003c/code\u003e的\u003ccode\u003eeventlog\u003c/code\u003e选项时，你应该在操作系统中注册一个事件源及其库，这样 Windows 事件查看器能够清楚地显示事件日志消息。详见\u003ca href=\"/docs/18/event-log-registration.html\" rel=\"nofollow\"\u003e第 18.12 节\u003c/a\u003e。\u003c/p\u003e\u003c/div\u003e","SourceRevision":"2026-09-11@29c86d9","ContentHash":"c0b7efe7f82166669e1a96916016a0cc4233ebe6e09aa64dedb8d750956a589d","Payload":{"carried_from":"","carry_reason":"","doc_html":"\u003cp\u003e\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e支持多种记录服务器消息的方法，包括 \u003cspan class=\"systemitem\"\u003estderr\u003c/span\u003e，\u003cspan class=\"systemitem\"\u003ecsvlog\u003c/span\u003e，\u003cspan class=\"systemitem\"\u003ejsonlog\u003c/span\u003e和 \u003cspan class=\"systemitem\"\u003esyslog\u003c/span\u003e。在Windows上，\u003cspan class=\"systemitem\"\u003eeventlog\u003c/span\u003e也受支持。将此参数设置为以逗号分隔的所需日志目的地列表。默认情况下仅记录到 \u003cspan class=\"systemitem\"\u003estderr\u003c/span\u003e。此参数只能在\u003ccode class=\"filename\"\u003epostgresql.conf\u003c/code\u003e 文件或服务器命令行中设置。\u003c/p\u003e\u003cp\u003e如果\u003cspan class=\"systemitem\"\u003ecsvlog\u003c/span\u003e被包括在\u003ccode class=\"varname\"\u003elog_destination\u003c/code\u003e中，日志项会以\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003e逗号分隔值\u003c/span\u003e”\u003c/span\u003e（CSV）格式被输出，这样可以很方便地把日志载入到程序中。详见\u003ca href=\"/docs/18/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-CSVLOG\" title=\"19.8.4. 使用 CSV 格式的日志输出\"\u003e第 19.8.4 节\u003c/a\u003e。要产生 CSV 格式的日志输出，必须启用\u003ca href=\"/docs/18/runtime-config-logging.html#GUC-LOGGING-COLLECTOR\"\u003elogging_collector\u003c/a\u003e。\u003c/p\u003e\u003cp\u003e如果\u003cspan class=\"systemitem\"\u003ejsonlog\u003c/span\u003e包含在\u003ccode class=\"varname\"\u003elog_destination\u003c/code\u003e中，日志条目将以JSON格式输出，这对将日志加载到程序中很方便。有关详细信息，请参见\u003ca href=\"/docs/18/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-JSONLOG\" title=\"19.8.5. 使用JSON格式的日志输出\"\u003e第 19.8.5 节\u003c/a\u003e。必须启用\u003ca href=\"/docs/18/runtime-config-logging.html#GUC-LOGGING-COLLECTOR\"\u003elogging_collector\u003c/a\u003e才能生成JSON格式的日志输出。\u003c/p\u003e\u003cp\u003e当包含\u003cspan class=\"systemitem\"\u003estderr\u003c/span\u003e、\u003cspan class=\"systemitem\"\u003ecsvlog\u003c/span\u003e或\u003cspan class=\"systemitem\"\u003ejsonlog\u003c/span\u003e时，文件\u003ccode class=\"filename\"\u003ecurrent_logfiles\u003c/code\u003e会被创建，记录日志收集器当前使用的日志文件位置和相关的日志目的地。这提供了一种方便的方式来查找实例当前使用的日志。以下是该文件内容的示例：\u003c/p\u003e\u003cpre\u003estderr log/postgresql.log\ncsvlog log/postgresql.csv\njsonlog log/postgresql.json\n\u003c/pre\u003e\u003cp\u003e当由于轮换而创建新的日志文件时，以及重新加载\u003ccode class=\"varname\"\u003elog_destination\u003c/code\u003e时，\u003ccode class=\"filename\"\u003ecurrent_logfiles\u003c/code\u003e会被重新创建。当\u003ccode class=\"varname\"\u003elog_destination\u003c/code\u003e中不包含\u003cspan class=\"systemitem\"\u003estderr\u003c/span\u003e、\u003cspan class=\"systemitem\"\u003ecsvlog\u003c/span\u003e或\u003cspan class=\"systemitem\"\u003ejsonlog\u003c/span\u003e，或者日志收集器被禁用时，它会被移除。\u003c/p\u003e\u003cdiv class=\"note\"\u003e\n注意\u003cp\u003e在大多数 Unix 系统上，你将需要修改系统的\u003cspan class=\"application\"\u003esyslog\u003c/span\u003e守护进程的配置来使用\u003ccode class=\"varname\"\u003elog_destination\u003c/code\u003e的\u003cspan class=\"systemitem\"\u003esyslog\u003c/span\u003e选项。\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e可以在\u003cspan class=\"application\"\u003esyslog\u003c/span\u003e设施\u003ccode class=\"literal\"\u003eLOCAL0\u003c/code\u003e到\u003ccode class=\"literal\"\u003eLOCAL7\u003c/code\u003e中记录（见\u003ca href=\"/docs/18/runtime-config-logging.html#GUC-SYSLOG-FACILITY\"\u003esyslog_facility\u003c/a\u003e），但是大部分平台上的默认\u003cspan class=\"application\"\u003esyslog\u003c/span\u003e配置会丢弃所有这种消息。你需要在\u003cspan class=\"application\"\u003esyslog\u003c/span\u003e守护进程的配置文件中增加类似以下的内容，使其生效：\u003c/p\u003e\u003cpre\u003elocal0.*    /var/log/postgresql\n\u003c/pre\u003e\u003cp\u003e在 Windows 上，当你使用\u003ccode class=\"varname\"\u003elog_destination\u003c/code\u003e的\u003ccode class=\"literal\"\u003eeventlog\u003c/code\u003e选项时，你应该在操作系统中注册一个事件源及其库，这样 Windows 事件查看器能够清楚地显示事件日志消息。详见\u003ca href=\"/docs/18/event-log-registration.html\" title=\"18.12. 在Windows上注册事件日志\"\u003e第 18.12 节\u003c/a\u003e。\u003c/p\u003e\u003c/div\u003e","doc_same_as":""}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
