{"Entry":{"collection":"guc","key":"log_filename","name":"log_filename","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Reporting and Logging / Where to Log","category_zh":"","changed_in":[],"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.3","status":"changed","to":"8.4"},{"documentation_changed":true,"fields":{},"from":"9.0","status":"changed","to":"9.1"},{"documentation_changed":true,"fields":{},"from":"14","status":"changed","to":"15"}],"content_hash":"e20d025783750945d91de76a9b6767a2bea9c881b74b69ce8f60ed50ad515cae","context":"","default_changed_in":[],"default_history":[{"from":"9.0","to":"19","value":"postgresql-%Y-%m-%d_%H%M%S.log"}],"editorial":{"advice":{"olap":"Choose a predictable period boundary for large analytical logs and ensure downstream ingestion closes the previous file before the pattern repeats; do not rely on size rotation with a non-unique name.","oltp":"Use a filename pattern whose uniqueness matches rotation policy. If names repeat, combine time-based rotation, log_truncate_on_rotation, and confirmed shipping so a reused name cannot mix periods or overwrite uncollected data.","small":"A bounded weekday or date pattern is reasonable only with matching retention and free-space monitoring. Keep enough time components to prevent accidental collisions after restart or manual rotation."},"mechanism":["log_filename sets the file name pattern for log files. logging_collector expands strftime escapes using log_timezone whenever it opens a new file, so repeating names must be coordinated with rotation and truncation.","log_filename 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_filename 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.","Using a repeating strftime name without matching rotation and truncation policy, causing append growth or overwrite surprises."],"references":[{"title":"PostgreSQL 19 Beta 4: log_filename","url":"https://www.postgresql.org/docs/19/runtime-config-logging.html#GUC-LOG-FILENAME"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["logging_collector","log_destination","log_directory","log_rotation_age","log_rotation_size"],"summary":"log_filename is the PostgreSQL setting that defines the file name pattern for log files."},"enumvals":[],"first_version":"8.0","group":"Reporting and Logging","group_slug":"logging","imported_at":"2026-09-30T00:40:57.334964+08:00","intro_commit":{},"key":"log_filename","last_version":"20","max_val":"","min_val":"","name":"log_filename","position":228,"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":"When logging_collector is enabled, this parameter sets the file names of the created log files.","short_desc_zh":"","source_rev":"english-manuals:676061ec11320f10705eebb647ddfb38d8517a4ff4c253b8170dbd4ad6286b6f","unit":"","vartype":"string"}},"Definition":{"Collection":"guc","Key":"log_filename","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"log_filename","SourceRevision":"english-manuals:676061ec11320f10705eebb647ddfb38d8517a4ff4c253b8170dbd4ad6286b6f","Facts":{"boot_val":"postgresql-%Y-%m-%d_%H%M%S.log","category":"Reporting and Logging / Where to Log","context":"sighup","description":"When logging_collector is enabled, this parameter sets the file names of the created log files. The value is treated as a strftime pattern, so %-escapes can be used to specify time-varying file names. (Note that if there are any time-zone-dependent %-escapes, the computation is done in the zone specified by log_timezone.) The supported %-escapes are similar to those listed in the Open Group's strftime specification. Note that the system's strftime is not used directly, so platform-specific (nonstandard) extensions do not work. The default is postgresql-%Y-%m-%d_%H%M%S.log. If you specify a file name without escapes, you should plan to use a log rotation utility to avoid eventually filling the entire disk. In releases prior to 8.4, if no % escapes were present, PostgreSQL would append the epoch of the new log file's creation time, but this is no longer the case. If CSV-format output is enabled in log_destination, .csv will be appended to the timestamped log file name to create the file name for CSV-format output. (If log_filename ends in .log, the suffix is replaced instead.) If JSON-format output is enabled in log_destination, .json will be appended to the timestamped log file name to create the file name for JSON-format output. (If log_filename ends in .log, the suffix is replaced instead.) This parameter can only be set in the postgresql.conf file or on the server command line.","doc":{"anchor":"GUC-LOG-FILENAME","file":"runtime-config-logging.html","lang":"en","sha256":"93c48c522a72fca19705c4c91a71e951eae653662008eee2e4a9a74a11127fde","slug":"18"},"documented":true,"enumvals":null,"extra_desc":null,"lang":"en","max_val":null,"metadata_version":"18","min_val":null,"name":"log_filename","short_desc":"Sets the file name pattern for log files.","source":"pg-settings-source-snapshot","unit":null,"vartype":"string"},"ManualEvidence":{"doc":{"anchor":"GUC-LOG-FILENAME","file":"runtime-config-logging.html","lang":"en","sha256":"93c48c522a72fca19705c4c91a71e951eae653662008eee2e4a9a74a11127fde","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"log_filename","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"log_filename","Summary":"","BodyHTML":"\u003cp\u003e当\u003ccode\u003elogging_collector\u003c/code\u003e被启用时，这个参数设置被创建的日志文件的文件名。该值被视为一种\u003ccode\u003estrftime\u003c/code\u003e模式，因此\u003ccode\u003e%\u003c/code\u003e转义可以被用来指定根据时间变化的文件名（注意如果有任何依赖时区的\u003ccode\u003e%\u003c/code\u003e转义，计算将在由\u003ca href=\"/docs/18/runtime-config-logging.html#GUC-LOG-TIMEZONE\" rel=\"nofollow\"\u003elog_timezone\u003c/a\u003e指定的时区中完成）。被支持的\u003ccode\u003e%\u003c/code\u003e转义和Open Group 的\u003ca href=\"https://pubs.opengroup.org/onlinepubs/009695399/functions/strftime.html\" rel=\"nofollow\"\u003estrftime\u003c/a\u003e规范中列举的类似。注意系统的\u003ccode\u003estrftime\u003c/code\u003e不会被直接使用，因此平台相关（非标准）的扩展无法工作。默认是\u003ccode\u003epostgresql-%Y-%m-%d_%H%M%S.log\u003c/code\u003e。\u003c/p\u003e\u003cp\u003e如果你不使用转义来指定一个文件名，你应该计划使用一个日志轮转工具来避免最终填满整个磁盘。在 8.4 发行之前，如果不存在\u003ccode\u003e%\u003c/code\u003e转义，\u003cspan\u003ePostgreSQL\u003c/span\u003e将追加新日志文件创建时的纪元时间戳，但是现在已经不再这样做了。\u003c/p\u003e\u003cp\u003e如果在\u003ccode\u003elog_destination\u003c/code\u003e中启用了 CSV 格式输出，\u003ccode\u003e.csv\u003c/code\u003e将会被追加到时间戳日志文件名中来创建 CSV 格式输出（如果\u003ccode\u003elog_filename\u003c/code\u003e以\u003ccode\u003e.log\u003c/code\u003e结尾，该后缀会被替换）。\u003c/p\u003e\u003cp\u003e如果在\u003ccode\u003elog_destination\u003c/code\u003e中启用了JSON格式的输出，时间戳日志文件名将会在末尾添加\u003ccode\u003e.json\u003c/code\u003e，以创建JSON格式输出的文件名。（如果\u003ccode\u003elog_filename\u003c/code\u003e以\u003ccode\u003e.log\u003c/code\u003e结尾，则会替换掉这个后缀。）\u003c/p\u003e\u003cp\u003e这个参数只能在\u003ccode\u003epostgresql.conf\u003c/code\u003e文件中或通过服务器命令行进行设置。\u003c/p\u003e","SourceRevision":"2026-09-11@29c86d9","ContentHash":"8cba2245a2064d5a2a249885946dc4873d6e675a085a27363cc963b65c49babb","Payload":{"carried_from":"","carry_reason":"","doc_html":"\u003cp\u003e当\u003ccode class=\"varname\"\u003elogging_collector\u003c/code\u003e被启用时，这个参数设置被创建的日志文件的文件名。该值被视为一种\u003ccode class=\"function\"\u003estrftime\u003c/code\u003e模式，因此\u003ccode class=\"literal\"\u003e%\u003c/code\u003e转义可以被用来指定根据时间变化的文件名（注意如果有任何依赖时区的\u003ccode class=\"literal\"\u003e%\u003c/code\u003e转义，计算将在由\u003ca href=\"/docs/18/runtime-config-logging.html#GUC-LOG-TIMEZONE\"\u003elog_timezone\u003c/a\u003e指定的时区中完成）。被支持的\u003ccode class=\"literal\"\u003e%\u003c/code\u003e转义和Open Group 的\u003ca href=\"https://pubs.opengroup.org/onlinepubs/009695399/functions/strftime.html\"\u003estrftime\u003c/a\u003e规范中列举的类似。注意系统的\u003ccode class=\"function\"\u003estrftime\u003c/code\u003e不会被直接使用，因此平台相关（非标准）的扩展无法工作。默认是\u003ccode class=\"literal\"\u003epostgresql-%Y-%m-%d_%H%M%S.log\u003c/code\u003e。\u003c/p\u003e\u003cp\u003e如果你不使用转义来指定一个文件名，你应该计划使用一个日志轮转工具来避免最终填满整个磁盘。在 8.4 发行之前，如果不存在\u003ccode class=\"literal\"\u003e%\u003c/code\u003e转义，\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e将追加新日志文件创建时的纪元时间戳，但是现在已经不再这样做了。\u003c/p\u003e\u003cp\u003e如果在\u003ccode class=\"varname\"\u003elog_destination\u003c/code\u003e中启用了 CSV 格式输出，\u003ccode class=\"literal\"\u003e.csv\u003c/code\u003e将会被追加到时间戳日志文件名中来创建 CSV 格式输出（如果\u003ccode class=\"varname\"\u003elog_filename\u003c/code\u003e以\u003ccode class=\"literal\"\u003e.log\u003c/code\u003e结尾，该后缀会被替换）。\u003c/p\u003e\u003cp\u003e如果在\u003ccode class=\"varname\"\u003elog_destination\u003c/code\u003e中启用了JSON格式的输出，时间戳日志文件名将会在末尾添加\u003ccode class=\"literal\"\u003e.json\u003c/code\u003e，以创建JSON格式输出的文件名。（如果\u003ccode class=\"varname\"\u003elog_filename\u003c/code\u003e以\u003ccode class=\"literal\"\u003e.log\u003c/code\u003e结尾，则会替换掉这个后缀。）\u003c/p\u003e\u003cp\u003e这个参数只能在\u003ccode class=\"filename\"\u003epostgresql.conf\u003c/code\u003e文件中或通过服务器命令行进行设置。\u003c/p\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}
