将所有查询记录在官方Postgres泊坞窗映像中 [英] Log all queries in the official Postgres docker image

查看:94
本文介绍了将所有查询记录在官方Postgres泊坞窗映像中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于Postgres官方docker镜像的docker容器.当我使用 docker logs -f 查看Docker容器的日志时,我想查看传入的查询.这是我的Dockerfile:

I have a docker container based on Postgres's official docker image. I want to see the incoming queries when I look at the logs of the docker container using docker logs -f. This is my Dockerfile:

FROM postgres:11.1-alpine

COPY mock_data.sql /docker-entrypoint-initdb.d/mock_data.sql

ENV PGDATA=/data

这是我的docker-compose.yml文件与此服务相关的部分:

and this is the part of my docker-compose.yml file related to this service:

version: '3'
services:
  mock_data:
    image: mock_data
    container_name: mock_data
    ports:
         - 5434:5432/tcp

在Docker日志中包括传入查询的最简单方法是什么?

What is the eaasiest way to include the incoming queries in docker logs?

推荐答案

如果使用Docker Compose,则可以将此行添加到 docker-compose.yaml 文件中:

If using Docker Compose, you can add this line to your docker-compose.yaml file:

command: ["postgres", "-c", "log_statement=all"]

,所有查询将被写入容器日志文件.

and all your queries will be written into the container log file.

这篇关于将所有查询记录在官方Postgres泊坞窗映像中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆