pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Greg Smith <gsmith@gregsmith.com>
To: c k <shreeseva.learning@gmail.com>
Cc: pgsql-general@postgresql.org
Subject: Re: logging SQL statements
Date: Thu, 9 Oct 2008 16:40:54 -0400 (EDT)
Message-ID: <Pine.GSO.4.64.0810091633380.16875@westnet.com> (raw)
In-Reply-To: <d8e7a1e30810090623i7766fc50xb46fc3e5efa3836@mail.gmail.com>
References: <d8e7a1e30810090623i7766fc50xb46fc3e5efa3836@mail.gmail.com>

On Thu, 9 Oct 2008, c k wrote:

> Is it possible to log all sql statements submitted to database server in 
> a table in that database it self?

It's possible to cobble together something to appoximate that without too 
much trouble if you're running V8.3.  You can use the CSV log format to 
make the logs show up in a tabular fashion: 
http://www.postgresql.org/docs/current/static/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-CSV...

And then you can change log_statement (on that same page) to "all".  The 
main tricky part is that you need to account for log rotation and such 
with whatever approach you take; you're on your own to figure out when the 
server is finished with a log such that you can import it, or to write 
something that imports more often.  It's possible to write something to 
use a "tail -f" type of approach that imports after every line is read, 
but that's harder.

BTW:  I'm dropping the admin list from my reply here because I'm not 
subscribed to that one at the moment.  It's bad form to cross-post to 
multiple lists here.  Pick the one you think you're more likely to get a 
response on first, and only if you don't get anything useful back after a 
wait should you submit your question to a second list.

--
* Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD



view thread (4+ messages)  latest in thread

Message-ID: <Pine.GSO.4.64.0810091633380.16875@westnet.com>
Permalink:  ../Pine.GSO.4.64.0810091633380.16875@westnet.com/
Also on:    postgresql.org/message-id/Pine.GSO.4.64.0810091633380.16875@westnet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: gsmith@gregsmith.com, shreeseva.learning@gmail.com, pgsql-general@postgresql.org
  Subject: Re: logging SQL statements
  In-Reply-To: <Pine.GSO.4.64.0810091633380.16875@westnet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox