Re: How to print application_name in log_line_prefix (using %a)?

From: Chris Angelico <rosuav(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to print application_name in log_line_prefix (using %a)?
Date: 2012-10-29 13:57:28
Message-ID: CAPTjJmr6DQ-8ckkv6_CK71E0rFyHK_XqKuxcKVUDsKLHhGbKUQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Oct 30, 2012 at 12:53 AM, Adrian Klaver <adrian(dot)klaver(at)gmail(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Janes 2012-10-29 15:35:13 Re: Why BgWriterDelay is fixed?
Previous Message Adrian Klaver 2012-10-29 13:53:34 Re: How to print application_name in log_line_prefix (using %a)?