There are some laws in my country that require me (as a service provider) to have a log which explains which person did what action. Now I know that PostgreSQL has a query log, but I was wondering if it also has some sort of identity management, so I also know which user ran the query.

I also realize that PostgreSQL can't know the user system in my application, but I was wondering if there is some sort of way where I can inform PostgreSQL which is the user table, session table and so on, so he can make the link automatically between an application user and a query. I know it's a long shot, but I thought I'd try.


If the application connects to PostgreSQL as just one user, the database has no way of identifying the actual user doing the query. This is solely the applications job which would need to log the actions it performs together with the actual user that is logged in to perform the action.

If the application doesn't do that and you have a legal need for it, you simply can't run this app in your country.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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