Skip to content
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

Log to stderr by turning off the log file collector #968

Merged
merged 1 commit into from
Jun 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ hot_standby = on
# ERROR REPORTING AND LOGGING
#------------------------------------------------------------------------------

log_filename = 'postgresql.log'
log_rotation_age = 0
log_destination = 'stderr'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, this is the default... but I added stderr to ensure this is explicit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to use stdout?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not an option in the settings: https://www.postgresql.org/docs/current/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-WHERE

Ultimately it's probably preferable to use jsonlog, but then I'm not sure you can do jsonlog and do to stderr.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not an option (stderr, csvlog, jsonlog, and syslog) according to https://www.postgresql.org/docs/current/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-WHERE. Perhaps it's to simplify things as log_collector "on" would need to redirect both stdout and stderr to logs.

log_collector

This parameter enables the logging collector, which is a background process that captures log messages sent to stderr and redirects them into log files

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Fryguy you beat me to it

# This is used when logging to stderr:
logging_collector = off
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what actually turns off logging to files and logs to stderr.


log_min_duration_statement = 5000
log_connections = on
log_disconnections = on
Comment on lines 46 to 47
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we drop these? It seemed very chatty in the demo env.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly? But, not here... I opened #969 to track the autovacuum settings but we can certainly review them all to see if we need those logged.

Expand Down