{"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"}],"derived_content_hash":"25ac01c899fcd07cededaa5a6c4eb9d2d77a1ed28115b3a843ad0abc712f97cc","documentation_refresh":{"batch":"20261113","original_source_rev":"wiki-repair-20261023:e737c7016fa1b90afdda08b44125bc4a445b8e890f69536b6f3bfd2e4086c8ab","versions":{"14":"14.25","15":"15.20","16":"16.16","17":"17.12","18":"18.7","19":"19rc2"}},"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"],"repair_provenance":{"original_source_revision":"english-manuals:676061ec11320f10705eebb647ddfb38d8517a4ff4c253b8170dbd4ad6286b6f","receipt_sha256":"0f7b956235e6d1114206c966acf5cef7d2f1e8babbb24d830be40cf9a329eae4","repair":"wiki-repair-20261023"},"short_desc":"When logging_collector is enabled, this parameter sets the file names of the created log files.","short_desc_zh":"","source_rev":"wiki-repair-20261023:e737c7016fa1b90afdda08b44125bc4a445b8e890f69536b6f3bfd2e4086c8ab","unit":"","vartype":"string"}},"Definition":{"Collection":"guc","Key":"log_filename","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"log_filename","SourceRevision":"wiki-repair-20261023:e737c7016fa1b90afdda08b44125bc4a445b8e890f69536b6f3bfd2e4086c8ab","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.","description_zh":"当 logging_collector 被启用时，这个参数设置被创建的日志文件的文件名。该值被视为一种 strftime 模式，因此% 转义可以被用来指定根据时间变化的文件名（注意如果有任何依赖时区的% 转义，计算将在由 log_timezone 指定的时区中完成）。被支持的% 转义和 Open Group 的 strftime 规范中列举的类似。注意系统的 strftime 不会被直接使用，因此平台相关（非标准）的扩展无法工作。默认是 postgresql-%Y-%m-%d_%H%M%S.log。 如果你不使用转义来指定一个文件名，你应该计划使用一个日志轮转工具来避免最终填满整个磁盘。在 8.4 发行之前，如果不存在% 转义，PostgreSQL 将追加新日志文件创建时的纪元时间戳，但是现在已经不再这样做了。 如果在 log_destination 中启用了 CSV 格式输出，.csv 将会被追加到时间戳日志文件名中来创建 CSV 格式输出（如果 log_filename 以.log 结尾，该后缀会被替换）。 如果在 log_destination 中启用了 JSON 格式的输出，时间戳日志文件名将会在末尾添加.json，以创建 JSON 格式输出的文件名。（如果 log_filename 以.log 结尾，则会替换掉这个后缀。） 这个参数只能在 postgresql.conf 文件中或通过服务器命令行进行设置。","description_zh_html":"\u003cp\u003e\n        当 \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 class=\"xref\" href=\"/zh/docs/18/runtime-config-logging.html#GUC-LOG-TIMEZONE\"\u003elog_timezone\u003c/a\u003e 指定的时区中完成）。被支持的\u003ccode class=\"literal\"\u003e%\u003c/code\u003e 转义和 Open Group 的 \u003ca class=\"ulink\" href=\"https://pubs.opengroup.org/onlinepubs/009695399/functions/strftime.html\" target=\"_top\"\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。\n       \u003c/p\u003e\u003cp\u003e\n        如果你不使用转义来指定一个文件名，你应该计划使用一个日志轮转工具来避免最终填满整个磁盘。在 8.4 发行之前，如果不存在\u003ccode class=\"literal\"\u003e%\u003c/code\u003e 转义，\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 将追加新日志文件创建时的纪元时间戳，但是现在已经不再这样做了。\n       \u003c/p\u003e\u003cp\u003e\n        如果在 \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 结尾，该后缀会被替换）。\n       \u003c/p\u003e\u003cp\u003e\n        如果在 \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 结尾，则会替换掉这个后缀。）\n       \u003c/p\u003e\u003cp\u003e\n        这个参数只能在 \u003ccode class=\"filename\"\u003epostgresql.conf\u003c/code\u003e 文件中或通过服务器命令行进行设置。\n       \u003c/p\u003e","doc":{"anchor":"GUC-LOG-FILENAME","file":"runtime-config-logging.html","lang":"en","sha256":"278d913b9c0f735c5cd7b35fd7205826bbd9c449805370d2dbe54105c0ed1d88","slug":"18"},"doc_html":"\u003cp\u003e\n        When \u003ccode class=\"varname\"\u003elogging_collector\u003c/code\u003e is enabled,\n        this parameter sets the file names of the created log files.  The value\n        is treated as a \u003ccode class=\"function\"\u003estrftime\u003c/code\u003e pattern,\n        so \u003ccode class=\"literal\"\u003e%\u003c/code\u003e-escapes can be used to specify time-varying\n        file names.  (Note that if there are\n        any time-zone-dependent \u003ccode class=\"literal\"\u003e%\u003c/code\u003e-escapes, the computation\n        is done in the zone specified\n        by \u003ca class=\"xref\" href=\"/docs/18/runtime-config-logging.html#GUC-LOG-TIMEZONE\"\u003elog_timezone\u003c/a\u003e.)\n        The supported \u003ccode class=\"literal\"\u003e%\u003c/code\u003e-escapes are similar to those\n        listed in the Open Group's \u003ca class=\"ulink\" href=\"https://pubs.opengroup.org/onlinepubs/009695399/functions/strftime.html\" target=\"_top\"\u003estrftime\n        \u003c/a\u003e specification.\n        Note that the system's \u003ccode class=\"function\"\u003estrftime\u003c/code\u003e is not used\n        directly, so platform-specific (nonstandard) extensions do not work.\n        The default is \u003ccode class=\"literal\"\u003epostgresql-%Y-%m-%d_%H%M%S.log\u003c/code\u003e.\n       \u003c/p\u003e\u003cp\u003e\n        If you specify a file name without escapes, you should plan to\n        use a log rotation utility to avoid eventually filling the\n        entire disk.  In releases prior to 8.4, if\n        no \u003ccode class=\"literal\"\u003e%\u003c/code\u003e escapes were\n        present, \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e would append\n        the epoch of the new log file's creation time, but this is no\n        longer the case.\n       \u003c/p\u003e\u003cp\u003e\n        If CSV-format output is enabled in \u003ccode class=\"varname\"\u003elog_destination\u003c/code\u003e,\n        \u003ccode class=\"literal\"\u003e.csv\u003c/code\u003e will be appended to the timestamped\n        log file name to create the file name for CSV-format output.\n        (If \u003ccode class=\"varname\"\u003elog_filename\u003c/code\u003e ends in \u003ccode class=\"literal\"\u003e.log\u003c/code\u003e, the suffix is\n        replaced instead.)\n       \u003c/p\u003e\u003cp\u003e\n        If JSON-format output is enabled in \u003ccode class=\"varname\"\u003elog_destination\u003c/code\u003e,\n        \u003ccode class=\"literal\"\u003e.json\u003c/code\u003e will be appended to the timestamped\n        log file name to create the file name for JSON-format output.\n        (If \u003ccode class=\"varname\"\u003elog_filename\u003c/code\u003e ends in \u003ccode class=\"literal\"\u003e.log\u003c/code\u003e, the suffix is\n        replaced instead.)\n       \u003c/p\u003e\u003cp\u003e\n        This parameter can only be set in the \u003ccode class=\"filename\"\u003epostgresql.conf\u003c/code\u003e\n        file or on the server command line.\n       \u003c/p\u003e","doc_same_as":"","documentation_revision":{"inputs":[{"file":"runtime-config-logging.html","kind":"same-version-reviewed-manual","locale":"en","sha256":"278d913b9c0f735c5cd7b35fd7205826bbd9c449805370d2dbe54105c0ed1d88","version":"18.7"},{"file":"runtime-config-logging.html","kind":"same-version-reviewed-manual","locale":"zh-Hans","sha256":"68c010254e1859ec0b76f06a563babd51a6c38997f1242e35e4c6b649724b1cb","version":"18.7"}],"release":"18.7","runtime_remeasured":false,"source_revision":"pgdoc:b9f0e7232f60f380d642ac9b99226606c254b552"},"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","translation_provenance":{"inputs":[{"kind":"current-pgdoc-translation","path":"/Users/vonng/pgsty/pgdoc/zh/18/html/runtime-config-logging.html","sha256":"a322f5293f10e348b5fc5dca98fdb6af52462723a215b8701c3b9d933e2933b4"}],"kind":"same-version-pgdoc","locale":"zh-Hans","source_revision":"b1b500221dbe5437cfca004d6b04d3f6e422765d","version":"18"},"unit":null,"vartype":"string","zh_from":"same-version-manual"},"ManualEvidence":{"doc":{"anchor":"GUC-LOG-FILENAME","file":"runtime-config-logging.html","lang":"en","sha256":"278d913b9c0f735c5cd7b35fd7205826bbd9c449805370d2dbe54105c0ed1d88","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"log_filename","SourceDatabase":"center","Version":"18","Locale":"en","Title":"log_filename","Summary":"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.","BodyHTML":"\u003cp\u003e\n        When \u003ccode\u003elogging_collector\u003c/code\u003e is enabled,\n        this parameter sets the file names of the created log files.  The value\n        is treated as a \u003ccode\u003estrftime\u003c/code\u003e pattern,\n        so \u003ccode\u003e%\u003c/code\u003e-escapes can be used to specify time-varying\n        file names.  (Note that if there are\n        any time-zone-dependent \u003ccode\u003e%\u003c/code\u003e-escapes, the computation\n        is done in the zone specified\n        by \u003ca href=\"/docs/18/runtime-config-logging.html#GUC-LOG-TIMEZONE\" rel=\"nofollow\"\u003elog_timezone\u003c/a\u003e.)\n        The supported \u003ccode\u003e%\u003c/code\u003e-escapes are similar to those\n        listed in the Open Group\u0026#39;s \u003ca href=\"https://pubs.opengroup.org/onlinepubs/009695399/functions/strftime.html\" rel=\"nofollow\"\u003estrftime\n        \u003c/a\u003e specification.\n        Note that the system\u0026#39;s \u003ccode\u003estrftime\u003c/code\u003e is not used\n        directly, so platform-specific (nonstandard) extensions do not work.\n        The default is \u003ccode\u003epostgresql-%Y-%m-%d_%H%M%S.log\u003c/code\u003e.\n       \u003c/p\u003e\u003cp\u003e\n        If you specify a file name without escapes, you should plan to\n        use a log rotation utility to avoid eventually filling the\n        entire disk.  In releases prior to 8.4, if\n        no \u003ccode\u003e%\u003c/code\u003e escapes were\n        present, \u003cspan\u003ePostgreSQL\u003c/span\u003e would append\n        the epoch of the new log file\u0026#39;s creation time, but this is no\n        longer the case.\n       \u003c/p\u003e\u003cp\u003e\n        If CSV-format output is enabled in \u003ccode\u003elog_destination\u003c/code\u003e,\n        \u003ccode\u003e.csv\u003c/code\u003e will be appended to the timestamped\n        log file name to create the file name for CSV-format output.\n        (If \u003ccode\u003elog_filename\u003c/code\u003e ends in \u003ccode\u003e.log\u003c/code\u003e, the suffix is\n        replaced instead.)\n       \u003c/p\u003e\u003cp\u003e\n        If JSON-format output is enabled in \u003ccode\u003elog_destination\u003c/code\u003e,\n        \u003ccode\u003e.json\u003c/code\u003e will be appended to the timestamped\n        log file name to create the file name for JSON-format output.\n        (If \u003ccode\u003elog_filename\u003c/code\u003e ends in \u003ccode\u003e.log\u003c/code\u003e, the suffix is\n        replaced instead.)\n       \u003c/p\u003e\u003cp\u003e\n        This parameter can only be set in the \u003ccode\u003epostgresql.conf\u003c/code\u003e\n        file or on the server command line.\n       \u003c/p\u003e","SourceRevision":"wiki-repair-20261023:e737c7016fa1b90afdda08b44125bc4a445b8e890f69536b6f3bfd2e4086c8ab","ContentHash":"4587d50baf75fdd0ae0caad3e18b43cba4aebd5df2dd22e5e72d3472cef14623","Payload":{"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."}},"RequestedLocale":"en","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}
