Using Heroku with the Postgresql add-on. Upon reviewing my logs, it seems postgresql is logging every ... single ... transaction. I understand you can set the log level by doing something like (https://www.postgresql.org/docs/9.1/static/runtime-config-logging.html)
ALTER DATABASE my_database SET log_statement=error;
However, Heroku says
ERROR: permission denied to set parameter "log_statement"
Note that might be a possible duplicate of how to turn off Heroku SQL logs from postgres but they never addressed how to get around the Heroku permissions. (Should I start a bounty on that ticket or keep this one?)
How do I modify the Heroku Postgresql logging levels?
Update
Folowing Get DB owner's name in PostgreSql
pg_catalog.pg_get_userbyid(d.datdba) as "Owner"
FROM pg_catalog.pg_database d
ORDER BY 1;
I get the following result
Name Owner
d7c0sfp134dmml u2mqn7a68c982v
postgres postgres
template0 postgres
template1 postgres
ALTER DATABASE d7c0sfp134dmml SET log_statement = error;
Results in
ERROR: permission denied to set parameter "log_statement" Query failed PostgreSQL said: permission denied to set parameter "log_statement"
As of August 8th 2017, Heroku Postgres now offers the ability to change this via the
PGSettings
feature. For example the command to log all statements on astandard-0
or above (no hobby plans) would be:ref: https://devcenter.heroku.com/articles/heroku-postgres-settings#log-statement
You interpreted documentation wrongly. The
log_statement
parameter doesn't allow theerror
value. Possible values are instead:none
,ddl
,mod
,all
(anddefault
pseudo-value).You may also want to change
log_min_messages
parameter orlog_min_error_statement
parameter. They allow these values:DEBUG5
,DEBUG4
,DEBUG3
,DEBUG2
,DEBUG1
,LOG
,NOTICE
,WARNING
,ERROR
,FATAL
andPANIC
. SetPANIC
for minimal logging.The fact is that for all three aforementioned parameters documentation says:
So, unless you can connect to PostgreSQL database as the
postgres
user or edit PostgreSQL configuration files directly, you probably cannot change logging options.You may ask Heroku support about some workarounds. But I don't see how you can change logging options, because they probably won't give you superuser access. Maybe you can ask them to do that for you (i.e. change logging options) or you can use some special tools to filter logs (without changing logging options), I don't know.