October 15th, 2012, 03:58 AM
Help on triggers
I have an application already running, accessing the database (postgresql 8.1). I need a solution, that prints (on a file, or somehow) the queries being executed every time the app accesses the database.
Is there any ON DATABASE ACCESS trigger ?!
Any idea how that can be done?
Thanks in advance.
October 15th, 2012, 11:11 AM
First: update to a supported version now. 8.1 is really, really old and should not be used any longer.
You can achieve this without a trigger. Just enable statement logging for Postgres in the file postgres.conf using the properties "log_duration"
More details in the manual: http://www.postgresql.org/docs/8.1/static/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-WHAT
with a modern version of Postgres you would have a more fined grained control over the actual statements being logged.
I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags.
Tips on how to ask better questions: