Add possibility to enable PostgreSQL query logging

This commit is contained in:
Disassembler 2017-09-20 11:35:13 +02:00
parent 0a232bcc22
commit 1f0f8ee451
2 changed files with 11 additions and 3 deletions

View File

@ -122,5 +122,13 @@ apt-get -y --no-install-recommends -y install postgresql-9.6 postgresql-9.6-post
cp ${SOURCE_DIR}/basic/etc/postgresql/9.6/main/postgresql.conf /etc/postgresql/9.6/main/postgresql.conf cp ${SOURCE_DIR}/basic/etc/postgresql/9.6/main/postgresql.conf /etc/postgresql/9.6/main/postgresql.conf
cp ${SOURCE_DIR}/basic/etc/postgresql/9.6/main/pg_hba.conf /etc/postgresql/9.6/main/pg_hba.conf cp ${SOURCE_DIR}/basic/etc/postgresql/9.6/main/pg_hba.conf /etc/postgresql/9.6/main/pg_hba.conf
# Enable query logging. Only if the DEBUG environment variable exists
if [ -n "${DEBUG}" ]; then
sed -i 's/#log_destination/log_destination/' /etc/postgresql/9.6/main/postgresql.conf
sed -i 's/#logging_collector/logging_collector/' /etc/postgresql/9.6/main/postgresql.conf
sed -i 's/#log_directory/log_directory/' /etc/postgresql/9.6/main/postgresql.conf
sed -i 's/#log_statement/log_statement/' /etc/postgresql/9.6/main/postgresql.conf
fi
# Restart # Restart
systemctl restart postgresql systemctl restart postgresql

View File

@ -334,13 +334,13 @@ effective_cache_size = 1GB
# requires logging_collector to be on. # requires logging_collector to be on.
# This is used when logging to stderr: # This is used when logging to stderr:
#logging_collector = off # Enable capturing of stderr and csvlog #logging_collector = on # Enable capturing of stderr and csvlog
# into log files. Required to be on for # into log files. Required to be on for
# csvlogs. # csvlogs.
# (change requires restart) # (change requires restart)
# These are only used if logging_collector is on: # These are only used if logging_collector is on:
#log_directory = 'pg_log' # directory where log files are written, #log_directory = '/var/log/postgresql' # directory where log files are written,
# can be absolute or relative to PGDATA # can be absolute or relative to PGDATA
#log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern, #log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern,
# can include strftime() escapes # can include strftime() escapes
@ -450,7 +450,7 @@ log_line_prefix = '%m [%p] %q%u@%d ' # special values:
# %% = '%' # %% = '%'
# e.g. '<%u%%%d> ' # e.g. '<%u%%%d> '
#log_lock_waits = off # log lock waits >= deadlock_timeout #log_lock_waits = off # log lock waits >= deadlock_timeout
#log_statement = 'none' # none, ddl, mod, all #log_statement = 'all' # none, ddl, mod, all
#log_replication_commands = off #log_replication_commands = off
#log_temp_files = -1 # log temporary files equal or larger #log_temp_files = -1 # log temporary files equal or larger
# than the specified size in kilobytes; # than the specified size in kilobytes;