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

From Chris Angelico
Subject Re: How to print application_name in log_line_prefix (using %a)?
Date
Msg-id CAPTjJmr6DQ-8ckkv6_CK71E0rFyHK_XqKuxcKVUDsKLHhGbKUQ@mail.gmail.com
Whole thread Raw
In response to Re: How to print application_name in log_line_prefix (using %a)?  (Adrian Klaver <adrian.klaver@gmail.com>)
List pgsql-general
On Tue, Oct 30, 2012 at 12:53 AM, Adrian Klaver <adrian.klaver@gmail.com> wrote:
> On 10/29/2012 04:00 AM, Chris Angelico wrote:
>>
>> Not sure what you mean by that, but my postgresql.conf doesn't have
>> anything about application_name. But if it did, it would be a default
>> that an application can override.
>
>
> Actually it does:
>
> log_line_prefix =  #   %a = application name
>                    #   %u = user name
>                    #   %d = database name
>
> http://www.postgresql.org/docs/9.2/interactive/runtime-config-logging.html#GUC-APPLICATION-NAME

Yep, but it doesn't have anything about _setting_ the app name. The
original question involved a postgresql.conf directive
"application_name = '....'", which I can't find any docs for, nor can
I find in my well-commented default config from the openscg install.

> It is a chicken and egg situation. See section 31.1.2. Parameter Key Words
> of below:
>
> http://www.postgresql.org/docs/9.2/interactive/libpq-connect.html
>
> "application_name
> Specifies a value for the application_name configuration parameter."

That's on the connection, which is where I'm recommending setting it.

There's no magic that picks up your application's executable name, but
you can of course pass argv[0] to libpq as the application_name.

ChrisA


pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: How to print application_name in log_line_prefix (using %a)?
Next
From: Jeff Janes
Date:
Subject: Re: Why BgWriterDelay is fixed?