Example of Logging Setup
qhb.conf settings:
- Enable logging: logging_collector = on;
- Enable logging to log files: log_directory = '/u01/db/log` the log directory must be defined locally. It can be an absolute path, but you can also specify a relative path ./log/;
- Set the logging level: log_min_messages = info or another suitable one;
- Parameter for the fact of logging into the system: log_connections = true;
- Enable logging of failed queries: log_min_error_statement=info;
- Enable connection hostname logging: log_hostname = true — it is advisable to log it in addition to the IP address for security or further debugging reasons;
- Enable logging of replication actions: log_replication_commands = true. Required for setting up high availability clusters;
- Enable logging of operations on the DBMS (for security reasons):
log_statement = 'none' # none, ddl, mod, all; - Generate a log line template to record the above parameters:
log_line_prefix = '%m [%p] ' # special values:
# %a = application name
# %u = user name
# %d = database name
# %r = remote host and port
# %h = remote host
# %p = process ID
# %t = timestamp without milliseconds
# %m = timestamp with milliseconds
# %n = timestamp with milliseconds (as a Unix epoch)
# %i = command tag
# %e = SQL state
# %c = session ID
# %l = session line number
# %s = session start timestamp
# %v = virtual transaction ID
# %x = transaction ID (0 if none)
# %q = stop here in non-session
# processes
# %% = '%'
# e.g. '<%u%%%d> '
Assembled example of a line with logging format:
%m [%p]: [%l] [txid=%x] user=%u, db=%d, app%a, client=%r