The question:
In PostgreSQL 12+ is it possible to have a log with all actions performed by a user/role?
Eg: If that user executes a query, delete, create table, pg_dump, etc, store what he did in a log.
The Solutions:
Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.
Method 1
You can set parameters per role:
ALTER ROLE user_to_log SET log_min_duration_statements = 0;
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0