#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    1
    Rep Power
    0

    Question Help on triggers


    Hello,
    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.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,784
    Rep Power
    348
    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.
    http://forums.devshed.com/misc.php?do=bbcode#code

    Tips on how to ask better questions:
    http://tkyte.blogspot.de/2005/06/how-to-ask-questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

IMN logo majestic logo threadwatch logo seochat tools logo