Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 3F3DE37BA5D for ; Thu, 9 Oct 2008 17:41:01 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 83715-01 for ; Thu, 9 Oct 2008 17:40:57 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from westnet.com (westnet.com [216.187.52.2]) by postgresql.org (Postfix) with ESMTP id 417D937BA4A for ; Thu, 9 Oct 2008 17:40:56 -0300 (ADT) Received: from westnet.com (localhost [127.0.0.1]) by westnet.com (8.14.0/8.14.0) with ESMTP id m99Kes5v020379; Thu, 9 Oct 2008 16:40:54 -0400 (EDT) Received: from localhost (gsmith@localhost) by westnet.com (8.14.0/8.13.2/Submit) with ESMTP id m99KeseL020376; Thu, 9 Oct 2008 16:40:54 -0400 (EDT) X-Authentication-Warning: westnet.com: gsmith owned process doing -bs Date: Thu, 9 Oct 2008 16:40:54 -0400 (EDT) From: Greg Smith X-X-Sender: gsmith@westnet.com To: c k cc: pgsql-general@postgresql.org Subject: Re: logging SQL statements In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200810/344 X-Sequence-Number: 138594 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-CSVLOG 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