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)
-
Calls
exec
with-T
to disable pseudo-TTY. The command to execute issed
. -
Using
sed
we modify thepostgresql.conf
config file enable sql statement logging, using0
for logging all statements.-i
insed
modifies the source file instead of priting to stdout -
Restart
postgres
container -
Restart
backend
container -
Show and follow
postgres
logs