Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id C07B3650222 for ; Tue, 22 Jul 2008 16:35:05 -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 80972-05-2 for ; Tue, 22 Jul 2008 16:34:35 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from ipmail01.adl6.internode.on.net (ipmail01.adl6.internode.on.net [203.16.214.146]) by postgresql.org (Postfix) with ESMTP id 26FB2650A8F for ; Tue, 22 Jul 2008 15:54:58 -0300 (ADT) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqAEAPLFhUjLevdH/2dsb2JhbAAsgS6vTA X-IronPort-AV: E=Sophos;i="4.31,232,1215354600"; d="scan'208";a="155332730" Received: from ppp247-71.static.internode.on.net (HELO DevBox.local) ([203.122.247.71]) by ipmail01.adl6.internode.on.net with ESMTP; 23 Jul 2008 04:17:52 +0930 Message-ID: <48862B57.2050402@Sheeky.Biz> Date: Wed, 23 Jul 2008 04:17:51 +0930 From: Shane Ambler User-Agent: Thunderbird 2.0.0.14 (Macintosh/20080421) MIME-Version: 1.0 To: Achilleas Mantzios CC: pgsql-admin@postgresql.org, Rajesh Kumar Mallah Subject: Re: conditional logging based on client References: <200807221524.45181.achill@matrix.gatewaynet.com> In-Reply-To: <200807221524.45181.achill@matrix.gatewaynet.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200807/187 X-Sequence-Number: 29797 Achilleas Mantzios wrote: > Στις Tuesday 22 July 2008 15:17:42 ο/η Rajesh Kumar Mallah > έγραψε: >> Hi, >> >> We want to log all SQLs that has been executed by using psql >> client. we do not want to use .psql_history as it is distributed >> and may be deleted by users . >> >> The original objective is that we should be able to know what all >> hand made SQLs have been executed in past (which can date back as >> long as 1 year even) > > You have to adjust log_statement in your postgresql.conf however you > will have to bear in mind the performance implications of this. > Normal production sites dont do this. You can enable/disable this > kind of logging any time by killing -HUP I am thinking that is a bit more than what you want. You can log all sql statements run on a server but the server can't differentiate between your custom-app sent sql and hand made sql sent through psql. I know you can add things like remote address, username, dbname, sessionid to the start of each log line but I don't know of getting the client app name. My thought would be to enable the statement logging and to modify your client apps to have a set comment at the beginning and end of all sql statements sent. You could then filter these sql statements out of the logs leaving you with hand crafted sql. -- Shane Ambler pgSQL (at) Sheeky (dot) Biz Get Sheeky @ http://Sheeky.Biz