4

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"

4
  • What username do you use to login to PostgreSQL? Does it corresponds to owner of my_database? Commented Oct 8, 2016 at 17:44
  • @Sasha Please see Update Commented Oct 12, 2016 at 18:35
  • OK, I see the owner of d7c0sfp134dmml. And what user do you log under? Just do SELECT current_user;. Commented Oct 12, 2016 at 18:48
  • @Sasha I log in under u2mqn7a68c982v Commented Oct 13, 2016 at 2:07

2 Answers 2

3

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 a standard-0 or above (no hobby plans) would be:

heroku pg:settings:log-statement all postgresql-large-1234 -a sushi

ref: https://devcenter.heroku.com/articles/heroku-postgres-settings#log-statement

Sign up to request clarification or add additional context in comments.

Comments

1
  1. You interpreted documentation wrongly. The log_statement parameter doesn't allow the error value. Possible values are instead: none, ddl, mod, all (and default pseudo-value).

    You may also want to change log_min_messages parameter or log_min_error_statement parameter. They allow these values: DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1, LOG, NOTICE, WARNING, ERROR, FATAL and PANIC. Set PANIC for minimal logging.

  2. The fact is that for all three aforementioned parameters documentation says:

    Only superusers can change this setting.

    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.

1 Comment

What's odd is that I don't get all these logging messages on my PostgreSql Hobby-Basic tier but I do on the Standard 0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.