-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
customize log verbosity #540
Comments
We could add that, although the errors will be in your db logs as well depending on your logging settings. |
Note there is more documentation now about debugging server problems - https://postgrest.readthedocs.io/en/v0.4/admin.html#debugging |
Revisiting this, a log level would be nice in order to both reduce logging (since it might be duplicating the logs of a proxy server), or turn them up. I propose we allow syslog style log levels. |
Hi, are there any progress on that ? |
When having several clients that access the database, it can be hard to pinpoint the log entries that belong to a particular pgrst instance. I think we should recommend using log_line_prefix and setting application_name in the connection uri(on
I was also thinking if we could somehow set the |
I have a counterpoint against doing more detailed logging in the syslog style. Recently, I helped an user that was in need of an audit trail for PostgREST events, this was needed for compliance with a standard. The idea was to have detailed request information in JSON(payload body, headers, success/error codes, etc) and then send them to Kafka for later processing. Naturally the first idea that comes to mind was to add more detailed logging in PostgREST itself and construct the required JSON. However, this detailed logging would introduce code paths that can lead to performance degradation. In the past we have had problems such as #690 and #925(#1206 still open btw). Those were fixed basically by not messing with the payload body in Haskell code and instead rely on directly sending it to pg through parametrized queries. So, why introduce these issues in PostgREST(we'd have to discuss what goes in a DEBUG level, which format, measure the memory consumption impact, go back to previous perf issues for certain settings, etc) when PostgreSQL logs can already be formatted in JSON(thanks to jsonlog, this was the eventual solution we landed on) with much more detailed information than what we could output in pgrst(certain error messages will not be exposed through libpq, see nikita-volkov/hasql#112). CSV logs are also already available in pg and I think PostgREST has remained and should still be a transparent layer over PostgreSQL. We could leave the detailed logging to PostgreSQL. In a way this would also reinforce our "db as the source of truth" principle. I propose we refrain from detailed logging and to always do minimal logging(not go to a higher level). Instead we should add to the docs a good explanation on logging with these recommendations #540 (comment) (we can include some log samples) and with a single |
A bit unrelated, but we could provide an option for error responses verbosity. Some users might not want to expose the full I've noted that we do |
For docs, we could also show how to set the log_min_messages per postgrest app. By recommending to set the setting per user(can also be done per db but probably not desired), like: |
A lower level of logging - for failed requests(status >=400):
Edit: Actually I'm not sure how to do this with the above interface. WAI is looking too low level. We might have to check how Yesod uses WAI to do logging levels: http://hackage.haskell.org/package/yesod-core-1.1.8.3/docs/Yesod-Core.html#v:LevelDebug |
another to options for the record:
|
One more reason to offer a lower log level, the verbose output makes the log file grow quickly. Also, one other thing I've noticed is that our connection retries messages go to So, looks like we should have a
Should |
+1 to set |
Hi,
Postgrest seems fantastic!
It would be nice to see logged near the requests submitted to postgrest, also the pg response errors.
What do you think?
The text was updated successfully, but these errors were encountered: