log_connections

A configuration parameter determining whether to log connections

log_connections is a configuration parameter determining whether to log connections.

log_connections was added in PostgreSQL 7.1.

Default value

The default value for log_connections is: off.

Usage

By default, PostgreSQL only logs the errors generated by unsuccessful connections.

If log_connections is set to on, details of successful and unsuccessful connections are also logged.

Change history

Examples

Sample log output for a successful connection when log_connections is on:

[2020-12-07 12:54:20 CET 192.168.1.2 [unknown]/[unknown] ] LOG:  connection received: host=192.168.1.2 port=56974
[2020-12-07 12:54:20 CET 192.168.1.2 postgres/postgres authentication] LOG:  connection authorized: user=postgres database=postgres application_name=psql

Sample log output for an unsuccessful connection when log_connections is off:

[2020-12-07 13:38:22 CET 192.168.1.2 postgres/postgree startup] FATAL:  database "postgree" does not exist

Sample log output for an unsuccessful connection when log_connections is on:

[2020-12-07 13:39:10 CET 192.168.1.2 [unknown]/[unknown] ] LOG:  connection received: host=192.168.1.2 port=59480
[2020-12-07 13:39:10 CET 192.168.1.2 postgres/postgree authentication] LOG:  connection authorized: user=postgres database=postgree application_name=psql
[2020-12-07 13:39:10 CET 192.168.1.2 postgres/postgree startup] FATAL:  database "postgree" does not exist

Categories

GUC configuration item, Logging