Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to make PostgreSQL log user creation, user deletion and change in user permissions?

share|improve this question

Yes, add in your postgresql.conf and restart (or just reload) db server:

log_statement = 'ddl'

That works with createuser, dropuser wrappers, CREATE/DROP ROLE/USER and ALTER ROLE/USER statements as I checked:

2011-05-23 14:40:45 CEST STATEMENT:  DROP ROLE thomas;
2011-05-23 14:40:52 CEST LOG:  statement: CREATE ROLE greg LOGIN CREATEDB;
2011-05-23 14:42:36 CEST LOG:  statement: ALTER ROLE greg NOCREATEDB;

log_statement (enum) - Controls which SQL statements are logged. Valid values are none (off), ddl, mod, and all (all statements). ddl logs all data definition statements, such as CREATE, ALTER, and DROP statements.

There is one drawback, that you have another DDL statements logged as well.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.