4

I'm not much familiar with postgresql. I like to setup postgres application_name feature to log database changes (update/delete) in a history table.

I tried to find any help from online but couldn't find any article with basic steps. Could someone give me any kind of help.

Thanks alot!

1 Answer 1

7

Using a application_name is great idea. It has a two steps:

  1. logging application name - set log_line_prefix in postgresql.conf
    log_line_prefix = '%a %u %d' 
  2. use application name - use SQL configuration statement or variable in connection string or environment variable
    SET application_name = 'myapp';
    or
    postgresql://other@localhost/otherdb?connect_timeout=10&application_name=myapp
    or
    PGAPPNAME=splunk psql -c "select application_name from pg_stat_activity where pid = pg_backend_pid();" postgres

some documentation

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.