How to print application_name in log_line_prefix (using %a)? - Mailing list pgsql-general

From Tianyin Xu
Subject How to print application_name in log_line_prefix (using %a)?
Date
Msg-id CABBDWweOGkTVKjLtW-RUqY2NeJQuxK+JV7kVJkcNYE3ND7xitw@mail.gmail.com
Whole thread Raw
Responses How to print application_name in log_line_prefix (using %a)?  (Tianyin Xu <tixu@ucsd.edu>)
Re: How to print application_name in log_line_prefix (using %a)?  (Chris Angelico <rosuav@gmail.com>)
List pgsql-general
Hi, guys,

Could anyone tell me how to specify the application_name as the log_line_prefix?

According to the manual at http://www.postgresql.org/docs/9.2/static/runtime-config-logging.html#GUC-APPLICATION-NAME:

"
application_name (string)

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...

"

and also, the manual entry for log_line_prefix (http://www.postgresql.org/docs/9.2/static/runtime-config-logging.html#GUC-LOG-LINE-PREFIX)

"
log_line_prefix (string)
This is a printf-style string that is output at the beginning of each log line. % characters begin "escape sequences" that are replaced with status information as outlined below...

%a      Application name
"

However, I have the following configuration settings in postgresql.conf

application_name = 'mypostgres'
log_line_prefix = '[%a] '


But, my log line is prefixed as "[] " like

[] LOG:  00000: database system was shut down at 2012-10-28 22:15:08 PDT
[] LOCATION:  StartupXLOG, xlog.c:6112
[] LOG:  00000: autovacuum launcher started
[] LOCATION:  AutoVacLauncherMain, autovacuum.c:407
[] LOG:  00000: database system is ready to accept connections
[] LOCATION:  reaper, postmaster.c:2408


Did I miss something?

Thanks a lot!
Tianyin


--
Tianyin XU,
http://cseweb.ucsd.edu/~tixu/

pgsql-general by date:

Previous
From: 高健
Date:
Subject: SPI_prepare's parameter
Next
From: Tianyin Xu
Date:
Subject: How to print application_name in log_line_prefix (using %a)?