Created
November 15, 2024 06:29
-
-
Save varaprasadh/fb544c9c447915c034fbc0e786c8600f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add to postgresql.conf | |
# Enable logging | |
logging_collector = on | |
log_directory = 'pg_log' # Directory where log files are written | |
log_filename = 'postgresql-%Y-%m-%d.log' # Daily log files | |
log_rotation_age = 1d # Rotate logs daily | |
log_rotation_size = 100MB # Also rotate when file reaches 100MB | |
# What to log | |
log_statement = 'all' # Log all SQL statements | |
log_min_duration_statement = 0 # Log all statements regardless of duration | |
# Add timestamp, user, and other useful info to each log line | |
log_line_prefix = '%t [%p]: [%l-1] user=%u,db=%d,client=%h ' | |
# %t = timestamp | |
# %p = process ID | |
# %l = log line number | |
# %u = user name | |
# %d = database name | |
# %h = client host | |
# Connection logging | |
log_connections = on # Log all connections | |
log_disconnections = on # Log all disconnections | |
log_duration = on # Log duration of each statement | |
# Error reporting | |
log_min_messages = warning # Minimum message level to log | |
log_min_error_statement = error # Log all error-causing statements |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment