'postgres: how to turn on logging?

I followed what is explained in How to log PostgreSQL queries? but the logging collector stays off.

    postgres=# show logging_collector;
    logging_collector
    -------------------
    off
    (1 row)

My postgresql.conf file Looks like this:

    listen_addresses = '*'
    tcpip_socket = true
    log_statement = 'all'
    log_connections = yes
    log_destination = 'syslog'
    logging_collector = on
    log_directory = '/var/log/pg_log'
    log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
    log_truncate_on_rotation = true
    log_rotation_age = 1440
    client_min_messages = LOG
    log_min_messages = INFO
    log_min_error_statement = DEBUG5
    log_min_duration_statement = 0


Solution 1:[1]

In my case I followed this documentation and it didn't show me the query logs (which was my intention) but it didn't work. Then I added these parameters to the postgres.conf file and the logs were shown:

event_source = 'PostgreSQL'

log_statement = 'all'

Both are commented out by default.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Angel Angeles