{"Entry":{"collection":"guc","key":"log_line_prefix","name":"log_line_prefix","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Reporting and Logging / What to Log","category_zh":"","changed_in":["10","18"],"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":"8.4","status":"changed","to":"9.0"},{"documentation_changed":true,"fields":{},"from":"9.1","status":"changed","to":"9.2"},{"documentation_changed":true,"fields":{},"from":"9.3","status":"changed","to":"9.4"},{"documentation_changed":true,"fields":{},"from":"9.4","status":"changed","to":"9.5"},{"documentation_changed":true,"fields":{},"from":"9.5","status":"changed","to":"9.6"},{"documentation_changed":true,"fields":{"boot_val":{"from":"","to":"%m [%p] "}},"from":"9.6","status":"changed","to":"10"},{"documentation_changed":true,"fields":{},"from":"12","status":"changed","to":"13"},{"documentation_changed":true,"fields":{},"from":"13","status":"changed","to":"14"},{"documentation_changed":true,"fields":{},"from":"15","status":"changed","to":"16"},{"documentation_changed":true,"fields":{},"from":"16","status":"changed","to":"17"},{"documentation_changed":true,"fields":{"extra_desc":{"from":"If blank, no prefix is used.","to":"An empty string means no prefix."}},"from":"17","status":"changed","to":"18"},{"documentation_changed":true,"fields":{},"from":"19","status":"changed","to":"20"}],"content_hash":"87afdece2539693bbd3ec88c314284cf047648fe9ff56d08c2448dc4bb02abb8","context":"","default_changed_in":["10"],"default_history":[{"from":"9.0","to":"9.6","value":"Empty string"},{"from":"10","to":"19","value":"%m [%p] "}],"derived_content_hash":"0f151ec3144e4e0a81b93f27c051e39f787940789c557de87da7a7e8e8d611fc","documentation_refresh":{"batch":"20261113","original_source_rev":"wiki-repair-20261023:0592072223342af8a9ec0043313f2bc3af3afc3eb7a21d38286b248d9b1b8ee7","versions":{"14":"14.25","15":"15.20","16":"16.16","17":"17.12","18":"18.7","19":"19rc2"}},"editorial":{"advice":{"olap":"Analytical jobs can justify richer log_line_prefix telemetry, but account for long statements, large bind values, and bursty completion patterns in the log pipeline.","oltp":"Tune log_line_prefix against an explicit observability question and a measured log-volume budget. Prefer selective thresholds, sampling, or role-level overrides over indiscriminate capture.","small":"Keep log_line_prefix useful but bounded: verify disk, collector, retention, and redaction capacity before increasing detail or frequency."},"mechanism":["log_line_prefix controls information prefixed to each log line. An empty string means no prefix. Percent escapes add session, user, database, process, application, and timing context; csvlog and jsonlog already carry structured fields separately.","log_line_prefix 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.","It changes emitted diagnostic data rather than query semantics, but volume, sensitive content, log_line_prefix, destinations, collector throughput, and retention determine operational cost and usefulness."],"pitfalls":["Editing log_line_prefix without reloading configuration and verifying the effective value and subsequent behavior.","Enabling richer logging without budgeting collector throughput, storage, retention, and downstream query cost.","Writing SQL text, bind values, identities, or host data without a redaction and access-control policy.","Omitting process, session, database, user, or application identity needed to correlate multiline text logs."],"references":[{"title":"PostgreSQL 19 Beta 4: log_line_prefix","url":"https://www.postgresql.org/docs/19/runtime-config-logging.html#GUC-LOG-LINE-PREFIX"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["application_name","cluster_name","update_process_title","log_timezone","log_hostname"],"summary":"log_line_prefix is the PostgreSQL setting that controls information prefixed to each log line."},"enumvals":[],"first_version":"8.0","group":"Reporting and Logging","group_slug":"logging","imported_at":"2026-09-30T00:40:57.350662+08:00","intro_commit":{},"key":"log_line_prefix","last_version":"20","max_val":"","min_val":"","name":"log_line_prefix","position":230,"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:e12cef740d6d81b35da3ef71d6040ab07f5358dc7b70758cd3e2b2ffbc8f6a0c","receipt_sha256":"2fab028bb37c7407cdb62f996e4fc7b9e07a82161408bc725d0ec87b32ca939d","repair":"wiki-repair-20261023"},"short_desc":"This is a printf-style string that is output at the beginning of each log line.","short_desc_zh":"","source_rev":"wiki-repair-20261023:0592072223342af8a9ec0043313f2bc3af3afc3eb7a21d38286b248d9b1b8ee7","unit":"","vartype":"string"}},"Definition":{"Collection":"guc","Key":"log_line_prefix","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"log_line_prefix","SourceRevision":"wiki-repair-20261023:0592072223342af8a9ec0043313f2bc3af3afc3eb7a21d38286b248d9b1b8ee7","Facts":{"boot_val":"%m [%p] ","category":"Reporting and Logging / What to Log","context":"sighup","description":"This is a printf-style string that is output at the beginning of each log entry that is sent to stderr, syslog, or eventlog. % characters begin “escape sequences” that are replaced with status information as outlined below. Unrecognized escapes are ignored. Other characters are copied straight to the log line. Some escapes are only recognized by session processes, and will be treated as empty by background processes such as the main server process. Status information may be aligned either left or right by specifying a numeric literal after the % and before the option. A negative value will cause the status information to be padded on the right with spaces to give it a minimum width, whereas a positive value will pad on the left. Padding can be useful to aid human readability in log files. This parameter can only be set in the postgresql.conf file or on the server command line. The default is '%m [%p] ' which logs a time stamp and the process ID. EscapeEffectSession only%aApplication nameyes%uUser nameyes%dDatabase nameyes%rRemote host name or IP address, and remote portyes%hRemote host name or IP addressyes%LLocal address (the IP address on the server that the client connected to)yes%bBackend typeno%pProcess IDno%PProcess ID of the parallel group leader, if this process is a parallel query workerno%tTime stamp without millisecondsno%mTime stamp with millisecondsno%nTime stamp with milliseconds (as a Unix epoch)no%iCommand tag: type of session's current commandyes%eSQLSTATE error codeno%cSession ID: see belowno%lNumber of the log line for each session or process, starting at 1no%sProcess start time stampno%vVirtual transaction ID (procNumber/localXID); see Section 67.1no%xTransaction ID (0 if none is assigned); see Section 67.1no%qProduces no output, but tells non-session processes to stop at this point in the string; ignored by session processesno%QQuery identifier of the current query. Query identifiers are not computed by default, so this field will be zero unless compute_query_id parameter is enabled or a third-party module that computes query identifiers is configured.yes%%Literal %no The backend type corresponds to the column backend_type in the view pg_stat_activity, but additional types can appear in the log that don't show in that view. The %c escape prints a quasi-unique session identifier, consisting of two 4-byte hexadecimal numbers (without leading zeros) separated by a dot. The numbers are the process start time and the process ID, so %c can also be used as a space saving way of printing those items. For example, to generate the session identifier from pg_stat_activity, use this query: SELECT to_hex(trunc(EXTRACT(EPOCH FROM backend_start))::integer) || '.' || to_hex(pid) FROM pg_stat_activity; Tip If you set a nonempty value for log_line_prefix, you should usually make its last character be a space, to provide visual separation from the rest of the log line. A punctuation character can be used too. Tip Syslog produces its own time stamp and process ID information, so you probably do not want to include those escapes if you are logging to syslog. Tip The %q escape is useful when including information that is only available in session (backend) context like user or database name. For example: log_line_prefix = '%m [%p] %q%u@%d/%a ' Note The %Q escape always reports a zero identifier for lines output by log_statement because log_statement generates output before an identifier can be calculated, including invalid statements for which an identifier cannot be calculated.","description_zh":"这是一个 printf 风格的字符串，它在每个发送到 stderr、syslog 或 eventlog 的日志条目开头输出。% 字符开始“转义序列”，它将按下文描述被替换为状态信息。未识别的转义被忽略。其他字符被直接复制到日志行。某些转义只被会话进程识别并且被主服务器进程等后台进程当作空。通过指定一个在% 之后和该选项之前的数字可以让状态信息左对齐或右对齐。负值将导致在右边用空格填充状态信息以达到最小宽度，而正值则在左边填充。填充对于日志文件的人类可读性大有帮助。 这个参数只能在 postgresql.conf 文件中或在服务器命令行上设置。默认值是'%m [%p] '，它记录时间戳和进程 ID。 转义效果只限会话%a应用名是%u用户名是%d数据库名是%r远程主机名或 IP 地址，以及远程端口是%h远程主机名或 IP 地址是%L本地地址（客户端所连接的服务器 IP 地址）是%b后端类型否%p进程 ID否%P如果该进程是并行查询工作进程，则为并行组领导者的进程 ID否%t无毫秒的时间戳否%m带毫秒的时间戳否%n带毫秒精度的 Unix 时间戳否%i命令标签：会话当前命令的类型是%eSQLSTATE 错误代码否%c会话 ID：见下文否%l对每个会话或进程的日志行号，从 1 开始否%s进程开始的时间戳否%v虚拟事务 ID（procNumber/localXID）；参见第 67.1 节否%x事务 ID（如果未分配则为 0）；参见第 67.1 节否%q不产生输出，但是告诉非会话进程在字符串的这一点停止；会话进程忽略否%Q当前查询的查询标识符。查询标识符默认是不计算的，所以该字段将为零，除非 compute_query_id 参数被激活或者配置了计算查询标识符的第三方模块是%%字面字符 %否 后端类型对应视图 pg_stat_activity 中的 backend_type 列。但是其他类型可能会出现在日志中而不显示在该视图中。 %c 转义打印一个准唯一的会话标识符，它由两个 4 字节的十六进制数（不带先导零）组成，以点号分隔。这些数字是进程启动时间和进程 ID，因此 %c 也可以用来节省空间地输出这两项信息。例如，要从 pg_stat_activity 生成会话标识符，使用这个查询： SELECT to_hex(trunc(EXTRACT(EPOCH FROM backend_start))::integer) || '.' || to_hex(pid) FROM pg_stat_activity; 提示 如果你为 log_line_prefix 设置了非空值，你通常应该让它的最后一个字符为空格，这样可与日志行的其余部分在视觉上区分开。也可以使用标点符号。 提示 Syslog 产生自己的时间戳和进程 ID 信息，因此如果你记录到 syslog 你可能不希望包括那些转义。 提示 在包括仅在会话（后端）上下文中可用的信息（如用户名或者数据库名）时，%q 转义很有用。例如： log_line_prefix = '%m [%p] %q%u@%d/%a ' 注意 对于 log_statement 输出的行，%Q 总是报告零标识符，因为 log_statement 在标识符能被计算之前生成输出，也包括无法计算标识符的无效语句。","description_zh_html":"\u003cp\u003e\n         这是一个 \u003ccode class=\"function\"\u003eprintf\u003c/code\u003e 风格的字符串，它在每个发送到 \u003ccode class=\"literal\"\u003estderr\u003c/code\u003e、\u003ccode class=\"literal\"\u003esyslog\u003c/code\u003e 或 \u003ccode class=\"literal\"\u003eeventlog\u003c/code\u003e 的日志条目开头输出。\u003ccode class=\"literal\"\u003e%\u003c/code\u003e 字符开始\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003e转义序列\u003c/span\u003e”\u003c/span\u003e，它将按下文描述被替换为状态信息。未识别的转义被忽略。其他字符被直接复制到日志行。某些转义只被会话进程识别并且被主服务器进程等后台进程当作空。通过指定一个在% 之后和该选项之前的数字可以让状态信息左对齐或右对齐。负值将导致在右边用空格填充状态信息以达到最小宽度，而正值则在左边填充。填充对于日志文件的人类可读性大有帮助。\n       \u003c/p\u003e\u003cp\u003e\n         这个参数只能在 \u003ccode class=\"filename\"\u003epostgresql.conf\u003c/code\u003e 文件中或在服务器命令行上设置。默认值是\u003ccode class=\"literal\"\u003e'%m [%p] '\u003c/code\u003e，它记录时间戳和进程 ID。\n       \u003c/p\u003e\u003cdiv class=\"informaltable\"\u003e\u003ctable border=\"1\" class=\"informaltable\"\u003e\u003ccolgroup\u003e\u003ccol/\u003e\u003ccol/\u003e\u003ccol/\u003e\u003c/colgroup\u003e\u003cthead\u003e\u003ctr\u003e\u003cth\u003e转义\u003c/th\u003e\u003cth\u003e效果\u003c/th\u003e\u003cth\u003e只限会话\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%a\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e应用名\u003c/td\u003e\u003ctd\u003e是\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%u\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e用户名\u003c/td\u003e\u003ctd\u003e是\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%d\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e数据库名\u003c/td\u003e\u003ctd\u003e是\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%r\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e远程主机名或 IP 地址，以及远程端口\u003c/td\u003e\u003ctd\u003e是\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%h\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e远程主机名或 IP 地址\u003c/td\u003e\u003ctd\u003e是\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%L\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e本地地址（客户端所连接的服务器 IP 地址）\u003c/td\u003e\u003ctd\u003e是\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%b\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e后端类型\u003c/td\u003e\u003ctd\u003e否\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%p\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e进程 ID\u003c/td\u003e\u003ctd\u003e否\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%P\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e如果该进程是并行查询工作进程，则为并行组领导者的进程 ID\u003c/td\u003e\u003ctd\u003e否\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%t\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e无毫秒的时间戳\u003c/td\u003e\u003ctd\u003e否\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%m\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e带毫秒的时间戳\u003c/td\u003e\u003ctd\u003e否\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%n\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e带毫秒精度的 Unix 时间戳\u003c/td\u003e\u003ctd\u003e否\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%i\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e命令标签：会话当前命令的类型\u003c/td\u003e\u003ctd\u003e是\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%e\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eSQLSTATE 错误代码\u003c/td\u003e\u003ctd\u003e否\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%c\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e会话 ID：见下文\u003c/td\u003e\u003ctd\u003e否\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%l\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e对每个会话或进程的日志行号，从 1 开始\u003c/td\u003e\u003ctd\u003e否\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%s\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e进程开始的时间戳\u003c/td\u003e\u003ctd\u003e否\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%v\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e虚拟事务 ID（procNumber/localXID）；参见\u003ca class=\"xref\" href=\"/zh/docs/18/transaction-id.html\" title=\"67.1. 事务与标识符\"\u003e第 67.1 节\u003c/a\u003e\u003c/td\u003e\u003ctd\u003e否\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%x\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e事务 ID（如果未分配则为 0）；参见\u003ca class=\"xref\" href=\"/zh/docs/18/transaction-id.html\" title=\"67.1. 事务与标识符\"\u003e第 67.1 节\u003c/a\u003e\u003c/td\u003e\u003ctd\u003e否\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%q\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e不产生输出，但是告诉非会话进程在字符串的这一点停止；会话进程忽略\u003c/td\u003e\u003ctd\u003e否\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%Q\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e当前查询的查询标识符。查询标识符默认是不计算的，所以该字段将为零，除非 \u003ca class=\"xref\" href=\"/zh/docs/18/runtime-config-statistics.html#GUC-COMPUTE-QUERY-ID\"\u003ecompute_query_id\u003c/a\u003e 参数被激活或者配置了计算查询标识符的第三方模块\u003c/td\u003e\u003ctd\u003e是\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%%\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e字面字符 \u003ccode class=\"literal\"\u003e%\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e否\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/div\u003e\u003cp\u003e\n          后端类型对应视图\u003ca class=\"link\" href=\"/zh/docs/18/monitoring-stats.html#MONITORING-PG-STAT-ACTIVITY-VIEW\" title=\"27.2.3. pg_stat_activity\"\u003e \u003ccode class=\"structname\"\u003epg_stat_activity\u003c/code\u003e\u003c/a\u003e 中的 \u003ccode class=\"structfield\"\u003ebackend_type\u003c/code\u003e 列。但是其他类型可能会出现在日志中而不显示在该视图中。\n         \u003c/p\u003e\u003cp\u003e\n\u003ccode class=\"literal\"\u003e%c\u003c/code\u003e 转义打印一个准唯一的会话标识符，它由两个 4 字节的十六进制数（不带先导零）组成，以点号分隔。这些数字是进程启动时间和进程 ID，因此 \u003ccode class=\"literal\"\u003e%c\u003c/code\u003e 也可以用来节省空间地输出这两项信息。例如，要从 \u003ccode class=\"literal\"\u003epg_stat_activity\u003c/code\u003e 生成会话标识符，使用这个查询：\n\u003c/p\u003e\u003cpre class=\"programlisting\"\u003e\nSELECT to_hex(trunc(EXTRACT(EPOCH FROM backend_start))::integer) || '.' ||\n       to_hex(pid)\nFROM pg_stat_activity;\n\u003c/pre\u003e\u003cp\u003e\n\u003c/p\u003e\u003cdiv class=\"tip\"\u003e\u003ch3 class=\"title\"\u003e提示\u003c/h3\u003e\u003cp\u003e\n         如果你为 \u003ccode class=\"varname\"\u003elog_line_prefix\u003c/code\u003e 设置了非空值，你通常应该让它的最后一个字符为空格，这样可与日志行的其余部分在视觉上区分开。也可以使用标点符号。\n        \u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"tip\"\u003e\u003ch3 class=\"title\"\u003e提示\u003c/h3\u003e\u003cp\u003e\n\u003cspan class=\"application\"\u003eSyslog\u003c/span\u003e 产生自己的时间戳和进程 ID 信息，因此如果你记录到 \u003cspan class=\"application\"\u003esyslog\u003c/span\u003e 你可能不希望包括那些转义。\n        \u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"tip\"\u003e\u003ch3 class=\"title\"\u003e提示\u003c/h3\u003e\u003cp\u003e\n         在包括仅在会话（后端）上下文中可用的信息（如用户名或者数据库名）时，\u003ccode class=\"literal\"\u003e%q\u003c/code\u003e 转义很有用。例如：\n\u003c/p\u003e\u003cpre class=\"programlisting\"\u003e\nlog_line_prefix = '%m [%p] %q%u@%d/%a '\n\u003c/pre\u003e\u003cp\u003e\n\u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"note\"\u003e\u003ch3 class=\"title\"\u003e注意\u003c/h3\u003e\u003cp\u003e\n         对于 \u003ca class=\"xref\" href=\"/zh/docs/18/runtime-config-logging.html#GUC-LOG-STATEMENT\"\u003elog_statement\u003c/a\u003e 输出的行，\u003ccode class=\"literal\"\u003e%Q\u003c/code\u003e 总是报告零标识符，因为 \u003ccode class=\"varname\"\u003elog_statement\u003c/code\u003e 在标识符能被计算之前生成输出，也包括无法计算标识符的无效语句。\n        \u003c/p\u003e\u003c/div\u003e","doc":{"anchor":"GUC-LOG-LINE-PREFIX","file":"runtime-config-logging.html","lang":"en","sha256":"278d913b9c0f735c5cd7b35fd7205826bbd9c449805370d2dbe54105c0ed1d88","slug":"18"},"doc_html":"\u003cp\u003e\n         This is a \u003ccode class=\"function\"\u003eprintf\u003c/code\u003e-style string that is output at the\n         beginning of each log entry that is sent to \u003ccode class=\"literal\"\u003estderr\u003c/code\u003e,\n         \u003ccode class=\"literal\"\u003esyslog\u003c/code\u003e, or \u003ccode class=\"literal\"\u003eeventlog\u003c/code\u003e.\n         \u003ccode class=\"literal\"\u003e%\u003c/code\u003e characters begin \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eescape sequences\u003c/span\u003e”\u003c/span\u003e\n         that are replaced with status information as outlined below.\n         Unrecognized escapes are ignored. Other\n         characters are copied straight to the log line. Some escapes are\n         only recognized by session processes, and will be treated as empty by\n         background processes such as the main server process. Status\n         information may be aligned either left or right by specifying a\n         numeric literal after the % and before the option. A negative\n         value will cause the status information to be padded on the\n         right with spaces to give it a minimum width, whereas a positive\n         value will pad on the left. Padding can be useful to aid human\n         readability in log files.\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. The default is\n         \u003ccode class=\"literal\"\u003e'%m [%p] '\u003c/code\u003e which logs a time stamp and the process ID.\n       \u003c/p\u003e\u003cdiv class=\"informaltable\"\u003e\u003ctable border=\"1\" class=\"informaltable\"\u003e\u003ccolgroup\u003e\u003ccol/\u003e\u003ccol/\u003e\u003ccol/\u003e\u003c/colgroup\u003e\u003cthead\u003e\u003ctr\u003e\u003cth\u003eEscape\u003c/th\u003e\u003cth\u003eEffect\u003c/th\u003e\u003cth\u003eSession only\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%a\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eApplication name\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%u\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eUser name\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%d\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eDatabase name\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%r\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eRemote host name or IP address, and remote port\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%h\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eRemote host name or IP address\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%L\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eLocal address (the IP address on the server that the\n             client connected to)\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%b\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eBackend type\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%p\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eProcess ID\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%P\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eProcess ID of the parallel group leader, if this process\n              is a parallel query worker\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%t\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eTime stamp without milliseconds\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%m\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eTime stamp with milliseconds\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%n\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eTime stamp with milliseconds (as a Unix epoch)\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%i\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eCommand tag: type of session's current command\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%e\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eSQLSTATE error code\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%c\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eSession ID: see below\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%l\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eNumber of the log line for each session or process, starting at 1\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%s\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eProcess start time stamp\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%v\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eVirtual transaction ID (procNumber/localXID);  see\n             \u003ca class=\"xref\" href=\"/docs/18/transaction-id.html\" title=\"67.1. Transactions and Identifiers\"\u003eSection 67.1\u003c/a\u003e\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%x\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eTransaction ID (0 if none is assigned);  see\n             \u003ca class=\"xref\" href=\"/docs/18/transaction-id.html\" title=\"67.1. Transactions and Identifiers\"\u003eSection 67.1\u003c/a\u003e\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%q\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eProduces no output, but tells non-session\n             processes to stop at this point in the string; ignored by\n             session processes\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%Q\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eQuery identifier of the current query.  Query\n             identifiers are not computed by default, so this field\n             will be zero unless \u003ca class=\"xref\" href=\"/docs/18/runtime-config-statistics.html#GUC-COMPUTE-QUERY-ID\"\u003ecompute_query_id\u003c/a\u003e\n             parameter is enabled or a third-party module that computes\n             query identifiers is configured.\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode class=\"literal\"\u003e%%\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eLiteral \u003ccode class=\"literal\"\u003e%\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/div\u003e\u003cp\u003e\n          The backend type corresponds to the column\n          \u003ccode class=\"structfield\"\u003ebackend_type\u003c/code\u003e in the view\n          \u003ca class=\"link\" href=\"/docs/18/monitoring-stats.html#MONITORING-PG-STAT-ACTIVITY-VIEW\" title=\"27.2.3. pg_stat_activity\"\u003e\n\u003ccode class=\"structname\"\u003epg_stat_activity\u003c/code\u003e\u003c/a\u003e,\n          but additional types can appear\n          in the log that don't show in that view.\n         \u003c/p\u003e\u003cp\u003e\n         The \u003ccode class=\"literal\"\u003e%c\u003c/code\u003e escape prints a quasi-unique session identifier,\n         consisting of two 4-byte hexadecimal numbers (without leading zeros)\n         separated by a dot.  The numbers are the process start time and the\n         process ID, so \u003ccode class=\"literal\"\u003e%c\u003c/code\u003e can also be used as a space saving way\n         of printing those items.  For example, to generate the session\n         identifier from \u003ccode class=\"literal\"\u003epg_stat_activity\u003c/code\u003e, use this query:\n\u003c/p\u003e\u003cpre class=\"programlisting\"\u003e\nSELECT to_hex(trunc(EXTRACT(EPOCH FROM backend_start))::integer) || '.' ||\n       to_hex(pid)\nFROM pg_stat_activity;\n\u003c/pre\u003e\u003cp\u003e\n\u003c/p\u003e\u003cdiv class=\"tip\"\u003e\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\u003cp\u003e\n         If you set a nonempty value for \u003ccode class=\"varname\"\u003elog_line_prefix\u003c/code\u003e,\n         you should usually make its last character be a space, to provide\n         visual separation from the rest of the log line.  A punctuation\n         character can be used too.\n        \u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"tip\"\u003e\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\u003cp\u003e\n\u003cspan class=\"application\"\u003eSyslog\u003c/span\u003e produces its own\n         time stamp and process ID information, so you probably do not want to\n         include those escapes if you are logging to \u003cspan class=\"application\"\u003esyslog\u003c/span\u003e.\n        \u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"tip\"\u003e\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\u003cp\u003e\n         The \u003ccode class=\"literal\"\u003e%q\u003c/code\u003e escape is useful when including information that is\n         only available in session (backend) context like user or database\n         name.  For example:\n\u003c/p\u003e\u003cpre class=\"programlisting\"\u003e\nlog_line_prefix = '%m [%p] %q%u@%d/%a '\n\u003c/pre\u003e\u003cp\u003e\n\u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"note\"\u003e\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\u003cp\u003e\n         The \u003ccode class=\"literal\"\u003e%Q\u003c/code\u003e escape always reports a zero identifier\n         for lines output by \u003ca class=\"xref\" href=\"/docs/18/runtime-config-logging.html#GUC-LOG-STATEMENT\"\u003elog_statement\u003c/a\u003e because\n         \u003ccode class=\"varname\"\u003elog_statement\u003c/code\u003e generates output before an\n         identifier can be calculated, including invalid statements for\n         which an identifier cannot be calculated.\n        \u003c/p\u003e\u003c/div\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":"An empty string means no prefix.","lang":"en","max_val":null,"metadata_version":"18","min_val":null,"name":"log_line_prefix","short_desc":"Controls information prefixed to each log line.","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-LINE-PREFIX","file":"runtime-config-logging.html","lang":"en","sha256":"278d913b9c0f735c5cd7b35fd7205826bbd9c449805370d2dbe54105c0ed1d88","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"log_line_prefix","SourceDatabase":"center","Version":"18","Locale":"en","Title":"log_line_prefix","Summary":"This is a printf-style string that is output at the beginning of each log entry that is sent to stderr, syslog, or eventlog. % characters begin “escape sequences” that are replaced with status information as outlined below. Unrecognized escapes are ignored. Other characters are copied straight to the log line. Some escapes are only recognized by session processes, and will be treated as empty by background processes such as the main server process. Status information may be aligned either left or right by specifying a numeric literal after the % and before the option. A negative value will cause the status information to be padded on the right with spaces to give it a minimum width, whereas a positive value will pad on the left. Padding can be useful to aid human readability in log files. This parameter can only be set in the postgresql.conf file or on the server command line. The default is '%m [%p] ' which logs a time stamp and the process ID. EscapeEffectSession only%aApplication nameyes%uUser nameyes%dDatabase nameyes%rRemote host name or IP address, and remote portyes%hRemote host name or IP addressyes%LLocal address (the IP address on the server that the client connected to)yes%bBackend typeno%pProcess IDno%PProcess ID of the parallel group leader, if this process is a parallel query workerno%tTime stamp without millisecondsno%mTime stamp with millisecondsno%nTime stamp with milliseconds (as a Unix epoch)no%iCommand tag: type of session's current commandyes%eSQLSTATE error codeno%cSession ID: see belowno%lNumber of the log line for each session or process, starting at 1no%sProcess start time stampno%vVirtual transaction ID (procNumber/localXID); see Section 67.1no%xTransaction ID (0 if none is assigned); see Section 67.1no%qProduces no output, but tells non-session processes to stop at this point in the string; ignored by session processesno%QQuery identifier of the current query. Query identifiers are not computed by default, so this field will be zero unless compute_query_id parameter is enabled or a third-party module that computes query identifiers is configured.yes%%Literal %no The backend type corresponds to the column backend_type in the view pg_stat_activity, but additional types can appear in the log that don't show in that view. The %c escape prints a quasi-unique session identifier, consisting of two 4-byte hexadecimal numbers (without leading zeros) separated by a dot. The numbers are the process start time and the process ID, so %c can also be used as a space saving way of printing those items. For example, to generate the session identifier from pg_stat_activity, use this query: SELECT to_hex(trunc(EXTRACT(EPOCH FROM backend_start))::integer) || '.' || to_hex(pid) FROM pg_stat_activity; Tip If you set a nonempty value for log_line_prefix, you should usually make its last character be a space, to provide visual separation from the rest of the log line. A punctuation character can be used too. Tip Syslog produces its own time stamp and process ID information, so you probably do not want to include those escapes if you are logging to syslog. Tip The %q escape is useful when including information that is only available in session (backend) context like user or database name. For example: log_line_prefix = '%m [%p] %q%u@%d/%a ' Note The %Q escape always reports a zero identifier for lines output by log_statement because log_statement generates output before an identifier can be calculated, including invalid statements for which an identifier cannot be calculated.","BodyHTML":"\u003cp\u003e\n         This is a \u003ccode\u003eprintf\u003c/code\u003e-style string that is output at the\n         beginning of each log entry that is sent to \u003ccode\u003estderr\u003c/code\u003e,\n         \u003ccode\u003esyslog\u003c/code\u003e, or \u003ccode\u003eeventlog\u003c/code\u003e.\n         \u003ccode\u003e%\u003c/code\u003e characters begin \u003cspan\u003e“\u003cspan\u003eescape sequences\u003c/span\u003e”\u003c/span\u003e\n         that are replaced with status information as outlined below.\n         Unrecognized escapes are ignored. Other\n         characters are copied straight to the log line. Some escapes are\n         only recognized by session processes, and will be treated as empty by\n         background processes such as the main server process. Status\n         information may be aligned either left or right by specifying a\n         numeric literal after the % and before the option. A negative\n         value will cause the status information to be padded on the\n         right with spaces to give it a minimum width, whereas a positive\n         value will pad on the left. Padding can be useful to aid human\n         readability in log files.\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. The default is\n         \u003ccode\u003e\u0026#39;%m [%p] \u0026#39;\u003c/code\u003e which logs a time stamp and the process ID.\n       \u003c/p\u003e\u003cdiv\u003e\u003ctable\u003e\u003ccolgroup\u003e\u003ccol/\u003e\u003ccol/\u003e\u003ccol/\u003e\u003c/colgroup\u003e\u003cthead\u003e\u003ctr\u003e\u003cth\u003eEscape\u003c/th\u003e\u003cth\u003eEffect\u003c/th\u003e\u003cth\u003eSession only\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e%a\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eApplication name\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e%u\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eUser name\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e%d\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eDatabase name\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e%r\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eRemote host name or IP address, and remote port\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e%h\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eRemote host name or IP address\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e%L\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eLocal address (the IP address on the server that the\n             client connected to)\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e%b\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eBackend type\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e%p\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eProcess ID\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e%P\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eProcess ID of the parallel group leader, if this process\n              is a parallel query worker\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e%t\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eTime stamp without milliseconds\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e%m\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eTime stamp with milliseconds\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e%n\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eTime stamp with milliseconds (as a Unix epoch)\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e%i\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eCommand tag: type of session\u0026#39;s current command\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e%e\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eSQLSTATE error code\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e%c\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eSession ID: see below\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e%l\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eNumber of the log line for each session or process, starting at 1\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e%s\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eProcess start time stamp\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e%v\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eVirtual transaction ID (procNumber/localXID);  see\n             \u003ca href=\"/docs/18/transaction-id.html\" rel=\"nofollow\"\u003eSection 67.1\u003c/a\u003e\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e%x\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eTransaction ID (0 if none is assigned);  see\n             \u003ca href=\"/docs/18/transaction-id.html\" rel=\"nofollow\"\u003eSection 67.1\u003c/a\u003e\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e%q\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eProduces no output, but tells non-session\n             processes to stop at this point in the string; ignored by\n             session processes\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e%Q\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eQuery identifier of the current query.  Query\n             identifiers are not computed by default, so this field\n             will be zero unless \u003ca href=\"/docs/18/runtime-config-statistics.html#GUC-COMPUTE-QUERY-ID\" rel=\"nofollow\"\u003ecompute_query_id\u003c/a\u003e\n             parameter is enabled or a third-party module that computes\n             query identifiers is configured.\u003c/td\u003e\u003ctd\u003eyes\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e%%\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eLiteral \u003ccode\u003e%\u003c/code\u003e\u003c/td\u003e\u003ctd\u003eno\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/div\u003e\u003cp\u003e\n          The backend type corresponds to the column\n          \u003ccode\u003ebackend_type\u003c/code\u003e in the view\n          \u003ca href=\"/docs/18/monitoring-stats.html#MONITORING-PG-STAT-ACTIVITY-VIEW\" rel=\"nofollow\"\u003e\n\u003ccode\u003epg_stat_activity\u003c/code\u003e\u003c/a\u003e,\n          but additional types can appear\n          in the log that don\u0026#39;t show in that view.\n         \u003c/p\u003e\u003cp\u003e\n         The \u003ccode\u003e%c\u003c/code\u003e escape prints a quasi-unique session identifier,\n         consisting of two 4-byte hexadecimal numbers (without leading zeros)\n         separated by a dot.  The numbers are the process start time and the\n         process ID, so \u003ccode\u003e%c\u003c/code\u003e can also be used as a space saving way\n         of printing those items.  For example, to generate the session\n         identifier from \u003ccode\u003epg_stat_activity\u003c/code\u003e, use this query:\n\u003c/p\u003e\u003cpre\u003e\nSELECT to_hex(trunc(EXTRACT(EPOCH FROM backend_start))::integer) || \u0026#39;.\u0026#39; ||\n       to_hex(pid)\nFROM pg_stat_activity;\n\u003c/pre\u003e\u003cp\u003e\n\u003c/p\u003e\u003cdiv\u003e\u003ch3\u003eTip\u003c/h3\u003e\u003cp\u003e\n         If you set a nonempty value for \u003ccode\u003elog_line_prefix\u003c/code\u003e,\n         you should usually make its last character be a space, to provide\n         visual separation from the rest of the log line.  A punctuation\n         character can be used too.\n        \u003c/p\u003e\u003c/div\u003e\u003cdiv\u003e\u003ch3\u003eTip\u003c/h3\u003e\u003cp\u003e\n\u003cspan\u003eSyslog\u003c/span\u003e produces its own\n         time stamp and process ID information, so you probably do not want to\n         include those escapes if you are logging to \u003cspan\u003esyslog\u003c/span\u003e.\n        \u003c/p\u003e\u003c/div\u003e\u003cdiv\u003e\u003ch3\u003eTip\u003c/h3\u003e\u003cp\u003e\n         The \u003ccode\u003e%q\u003c/code\u003e escape is useful when including information that is\n         only available in session (backend) context like user or database\n         name.  For example:\n\u003c/p\u003e\u003cpre\u003e\nlog_line_prefix = \u0026#39;%m [%p] %q%u@%d/%a \u0026#39;\n\u003c/pre\u003e\u003cp\u003e\n\u003c/p\u003e\u003c/div\u003e\u003cdiv\u003e\u003ch3\u003eNote\u003c/h3\u003e\u003cp\u003e\n         The \u003ccode\u003e%Q\u003c/code\u003e escape always reports a zero identifier\n         for lines output by \u003ca href=\"/docs/18/runtime-config-logging.html#GUC-LOG-STATEMENT\" rel=\"nofollow\"\u003elog_statement\u003c/a\u003e because\n         \u003ccode\u003elog_statement\u003c/code\u003e generates output before an\n         identifier can be calculated, including invalid statements for\n         which an identifier cannot be calculated.\n        \u003c/p\u003e\u003c/div\u003e","SourceRevision":"wiki-repair-20261023:0592072223342af8a9ec0043313f2bc3af3afc3eb7a21d38286b248d9b1b8ee7","ContentHash":"f325bdb58cd1c4d0c7a24cd13c12d2a99d1ee2c4d07e7f0333f8c78cb4b1d02b","Payload":{"description":"This is a printf-style string that is output at the beginning of each log entry that is sent to stderr, syslog, or eventlog. % characters begin “escape sequences” that are replaced with status information as outlined below. Unrecognized escapes are ignored. Other characters are copied straight to the log line. Some escapes are only recognized by session processes, and will be treated as empty by background processes such as the main server process. Status information may be aligned either left or right by specifying a numeric literal after the % and before the option. A negative value will cause the status information to be padded on the right with spaces to give it a minimum width, whereas a positive value will pad on the left. Padding can be useful to aid human readability in log files. This parameter can only be set in the postgresql.conf file or on the server command line. The default is '%m [%p] ' which logs a time stamp and the process ID. EscapeEffectSession only%aApplication nameyes%uUser nameyes%dDatabase nameyes%rRemote host name or IP address, and remote portyes%hRemote host name or IP addressyes%LLocal address (the IP address on the server that the client connected to)yes%bBackend typeno%pProcess IDno%PProcess ID of the parallel group leader, if this process is a parallel query workerno%tTime stamp without millisecondsno%mTime stamp with millisecondsno%nTime stamp with milliseconds (as a Unix epoch)no%iCommand tag: type of session's current commandyes%eSQLSTATE error codeno%cSession ID: see belowno%lNumber of the log line for each session or process, starting at 1no%sProcess start time stampno%vVirtual transaction ID (procNumber/localXID); see Section 67.1no%xTransaction ID (0 if none is assigned); see Section 67.1no%qProduces no output, but tells non-session processes to stop at this point in the string; ignored by session processesno%QQuery identifier of the current query. Query identifiers are not computed by default, so this field will be zero unless compute_query_id parameter is enabled or a third-party module that computes query identifiers is configured.yes%%Literal %no The backend type corresponds to the column backend_type in the view pg_stat_activity, but additional types can appear in the log that don't show in that view. The %c escape prints a quasi-unique session identifier, consisting of two 4-byte hexadecimal numbers (without leading zeros) separated by a dot. The numbers are the process start time and the process ID, so %c can also be used as a space saving way of printing those items. For example, to generate the session identifier from pg_stat_activity, use this query: SELECT to_hex(trunc(EXTRACT(EPOCH FROM backend_start))::integer) || '.' || to_hex(pid) FROM pg_stat_activity; Tip If you set a nonempty value for log_line_prefix, you should usually make its last character be a space, to provide visual separation from the rest of the log line. A punctuation character can be used too. Tip Syslog produces its own time stamp and process ID information, so you probably do not want to include those escapes if you are logging to syslog. Tip The %q escape is useful when including information that is only available in session (backend) context like user or database name. For example: log_line_prefix = '%m [%p] %q%u@%d/%a ' Note The %Q escape always reports a zero identifier for lines output by log_statement because log_statement generates output before an identifier can be calculated, including invalid statements for which an identifier cannot be calculated."}},"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}
