Postgres dockerized: enable query logging

Elvis Ciotti
Jan 18, 2024

--

Change your docker-compose.yml adding the command below

version: '3'

services:
postgresql:
image: /postgres:latest
container_name: postgresql
ports:
- "5432:5432"
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: secret
restart: always
command: ["postgres", "-c", "log_statement=all", "-c", "log_destination=stderr"]

stop and restart, then run docker-compose logs -f postgresl to see also logs printed out to the stderr

--

--

Elvis Ciotti
Elvis Ciotti

Written by Elvis Ciotti

Software Contractor — Java, Spring, k8s, AWS, Javascript @ London - hire me at https://elvisciotti.github.io/

No responses yet