{"Entry":{"collection":"guc","key":"application_name","name":"application_name","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Reporting and Logging / What to Log","category_zh":"","changed_in":[],"changes":[{"documentation_changed":false,"fields":{},"from":"8.4","status":"added","to":"9.0"},{"documentation_changed":true,"fields":{},"from":"15","status":"changed","to":"16"}],"content_hash":"4b2b386a69ad39406579aa4ba79a3221067ed1bac9ed25fb619fe5aaf5117ed9","context":"","default_changed_in":[],"default_history":[{"from":"9.0","to":"19","value":"Empty string"}],"editorial":{"advice":{"olap":"Set a stable job or tool family label and place run-specific high-cardinality identity elsewhere. Correlate long analytical sessions with authenticated role and session ID.","oltp":"Require each service and pooler to set a short, stable, non-secret application_name at checkout and reset it before reuse. Use controlled naming conventions, but never authorize or audit solely from this value.","small":"Keep labels compact and useful; node size is irrelevant. Avoid embedding tenant IDs, tokens, SQL, or unbounded request identifiers in a 64-character client-controlled field."},"mechanism":["application_name is client-supplied session metadata, usually set in the startup packet or later with SET. It appears in pg_stat_activity and CSV logs and can be inserted into text logs with the %a escape in log_line_prefix.","The value is shorter than NAMEDATALEN bytes (64 characters in a standard build). PostgreSQL permits printable ASCII; other characters are rendered as C-style hexadecimal escapes. Truncation and escaping mean log consumers must not assume the displayed value exactly matches an application's original string.","It is a USER-context label and is not authenticated identity: any authorized client can claim a misleading value and a pooled session can retain or overwrite it. Correlate it with authenticated user, database, session ID, remote endpoint, and controlled pool checkout/reset behavior."],"pitfalls":["Treating application_name as authenticated identity or using it alone for authorization, billing, or audit attribution.","Exceeding NAMEDATALEN and silently losing distinguishing suffixes through truncation.","Assuming arbitrary Unicode is preserved rather than escaped to printable C-style hexadecimal sequences.","Leaking secrets or creating unbounded cardinality in logs and pg_stat_activity, or failing to reset the value in a connection pool."],"references":[{"title":"PostgreSQL 19 Beta 4: application_name","url":"https://www.postgresql.org/docs/19/runtime-config-logging.html#GUC-APPLICATION-NAME"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["cluster_name","update_process_title","log_line_prefix","log_timezone","log_hostname"],"summary":"application_name is the PostgreSQL setting that defines the application name to be reported in statistics and logs."},"enumvals":[],"first_version":"9.0","group":"Reporting and Logging","group_slug":"logging","imported_at":"2026-09-30T00:40:56.551622+08:00","intro_commit":{},"key":"application_name","last_version":"20","max_val":"","min_val":"","name":"application_name","position":7,"present_in":["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":"The application_name can be any string of less than NAMEDATALEN characters (64 characters in a standard build).","short_desc_zh":"","source_rev":"english-manuals:6c290bdb73d9bad6952fbcc0e2447f450faffae51360e8dd7b57b627cb68499c","unit":"","vartype":"string"}},"Definition":{"Collection":"guc","Key":"application_name","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"application_name","SourceRevision":"english-manuals:6c290bdb73d9bad6952fbcc0e2447f450faffae51360e8dd7b57b627cb68499c","Facts":{"boot_val":"","category":"Reporting and Logging / What to Log","context":"user","description":"The application_name can be any string of less than NAMEDATALEN characters (64 characters in a standard build). It is typically set by an application upon connection to the server. The name will be displayed in the pg_stat_activity view and included in CSV log entries. It can also be included in regular log entries via the log_line_prefix parameter. Only printable ASCII characters may be used in the application_name value. Other characters are replaced with C-style hexadecimal escapes.","doc":{"anchor":"GUC-APPLICATION-NAME","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":"application_name","short_desc":"Sets the application name to be reported in statistics and logs.","source":"pg-settings-source-snapshot","unit":null,"vartype":"string"},"ManualEvidence":{"doc":{"anchor":"GUC-APPLICATION-NAME","file":"runtime-config-logging.html","lang":"en","sha256":"93c48c522a72fca19705c4c91a71e951eae653662008eee2e4a9a74a11127fde","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"application_name","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"application_name","Summary":"","BodyHTML":"\u003cp\u003e\u003ccode\u003eapplication_name\u003c/code\u003e可以是任意小于\u003ccode\u003eNAMEDATALEN\u003c/code\u003e个字符（标准编译中是 64 个字符）的字符串。应用通常在连接服务器时设置此值。该名称将被显示在\u003ccode\u003epg_stat_activity\u003c/code\u003e视图中并被包括在 CSV 日志项中。也可以通过\u003ca href=\"/docs/18/runtime-config-logging.html#GUC-LOG-LINE-PREFIX\" rel=\"nofollow\"\u003elog_line_prefix\u003c/a\u003e将其包括在普通日志项中。只有可打印 ASCII 字符能被使用在\u003ccode\u003eapplication_name\u003c/code\u003e之中。其他字符将被替换为\u003ca href=\"/docs/18/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-ESCAPE\" rel=\"nofollow\"\u003eC 风格的十六进制转义序列\u003c/a\u003e。\u003c/p\u003e","SourceRevision":"2026-09-11@29c86d9","ContentHash":"4da508e61ddb40c57ddac4dee1286b197c270f2b4e76f700d43c3ef67d3678a1","Payload":{"carried_from":"","carry_reason":"","doc_html":"\u003cp\u003e\u003ccode class=\"varname\"\u003eapplication_name\u003c/code\u003e可以是任意小于\u003ccode class=\"symbol\"\u003eNAMEDATALEN\u003c/code\u003e个字符（标准编译中是 64 个字符）的字符串。应用通常在连接服务器时设置此值。该名称将被显示在\u003ccode class=\"structname\"\u003epg_stat_activity\u003c/code\u003e视图中并被包括在 CSV 日志项中。也可以通过\u003ca href=\"/docs/18/runtime-config-logging.html#GUC-LOG-LINE-PREFIX\"\u003elog_line_prefix\u003c/a\u003e将其包括在普通日志项中。只有可打印 ASCII 字符能被使用在\u003ccode class=\"varname\"\u003eapplication_name\u003c/code\u003e之中。其他字符将被替换为\u003ca href=\"/docs/18/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-ESCAPE\" title=\"4.1.2.2. C风格转义的字符串常量\"\u003eC 风格的十六进制转义序列\u003c/a\u003e。\u003c/p\u003e","doc_same_as":""}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","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}
