log_statement setting

Started by Jayadevan Mover 4 years ago5 messagesgeneral
Jump to latest
#1Jayadevan M
maymala.jayadevan@gmail.com

Hello all,

A doubt on the setting 'log_statement'. Is it possible to set this at
database/user level?
I get 'all' when I try
select * from pg_settings where name = 'log_statement'
Does this mean all statements by any user on any database in that server
are getting logged? This is for auditing purposes.

Regards,
Jayadevan

#2Bruce Momjian
bruce@momjian.us
In reply to: Jayadevan M (#1)
Re: log_statement setting

On Wed, Aug 18, 2021 at 09:34:08PM +0530, Jayadevan M wrote:

Hello all,

A doubt on the setting  'log_statement'. Is it possible to set this at database
/user level?

Sure, ALTER USER/DATABASE ... SET.

I get 'all' when I try
select * from pg_settings where name = 'log_statement'
Does this mean all statements by any user on any database in that server are
getting logged? This is for auditing purposes.

Yes.

--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EDB https://enterprisedb.com

If only the physical world exists, free will is an illusion.

#3Jayadevan M
maymala.jayadevan@gmail.com
In reply to: Bruce Momjian (#2)
Re: log_statement setting

On Wed, Aug 18, 2021 at 9:36 PM Bruce Momjian <bruce@momjian.us> wrote:

On Wed, Aug 18, 2021 at 09:34:08PM +0530, Jayadevan M wrote:

Hello all,

A doubt on the setting 'log_statement'. Is it possible to set this at

database

/user level?

Sure, ALTER USER/DATABASE ... SET.

Thank you. Follow up question- If it is set to different values for
different users/databases, how can I get those values? For example,
I have a server with 4 databases. If I just query pg_settings, I get only
one value.

I get 'all' when I try
select * from pg_settings where name = 'log_statement'
Does this mean all statements by any user on any database in that server

are

getting logged? This is for auditing purposes.

Yes.

Thanks.

#4Julien Rouhaud
rjuju123@gmail.com
In reply to: Jayadevan M (#3)
Re: log_statement setting

On Thu, Aug 19, 2021 at 1:55 PM Jayadevan M <maymala.jayadevan@gmail.com> wrote:

Thank you. Follow up question- If it is set to different values for different users/databases, how can I get those values? For example,
I have a server with 4 databases. If I just query pg_settings, I get only one value.

The value you see on pg_settings is the one that's selected for your
current connection, based on the database/role you used.

You can use \drds in psql to see the various configurations, or query
the pg_db_role_setting table.

#5Jayadevan M
maymala.jayadevan@gmail.com
In reply to: Julien Rouhaud (#4)
Re: log_statement setting

On Thu, Aug 19, 2021 at 11:41 AM Julien Rouhaud <rjuju123@gmail.com> wrote:

The value you see on pg_settings is the one that's selected for your
current connection, based on the database/role you used.

You can use \drds in psql to see the various configurations, or query
the pg_db_role_setting table.

Thank you. Pointing to pg_db_role_setting was very helpful. I was able to
get the data I wanted.
Regards,
Jay