Skip to content

Instantly share code, notes, and snippets.

@iperdomo
Last active April 30, 2020 14:07
Show Gist options
  • Save iperdomo/afcc15c406f852960169c60b5a7cdee3 to your computer and use it in GitHub Desktop.
Save iperdomo/afcc15c406f852960169c60b5a7cdee3 to your computer and use it in GitHub Desktop.
docker-compose exec -T postgres \ # (1)
               sed -i -e "s/^#log_destination/log_destination/"  -e "s/^#log_min_error_statement = error/log_min_error_statement = info/" -e "s/^#log_min_duration_statement = -1/log_min_duration_statement = 0/" -e "s/^#log_min_messages = warning/log_min_messages = info/" /var/lib/postgresql/data/postgresql.conf && \ # (2)
docker-compose restart postgres && \ # (3)
docker-compose restart backend && \ # (4)
docker-compose logs --no-color --follow postgres # (5)
  1. Calls exec with -T to disable pseudo-TTY. The command to execute is sed.

  2. Using sed we modify the postgresql.conf config file enable sql statement logging, using 0 for logging all statements. -i in sed modifies the source file instead of priting to stdout

  3. Restart postgres container

  4. Restart backend container

  5. Show and follow postgres logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment