我很难在Docker中配置Postgres记录级别。从记录级别,我的意思是说我的查询就像 - 从tablethatnotexist
中选择计数(*),然后在数据库驱动程序返回的输出中会告诉我,以某种方式 - 关系“ tablethatnotexist”不存在
。
直到这里还可以,但是在数据库中获得相同的日志只是令人讨厌。我的意思是,我知道我以这种关系来查询数据,我也得到了回应。 日志
因此,获取像 -
没有任何意义,而且仅在文件中添加了额外的日志。
我已经搜索了所有的搜索,但是我只是找不到禁用额外记录的方法,或者只是将其设置为登录关键错误,因为数据库驱动程序会处理最多的错误。
我的开发环境 -
Docker Compose Postgres
服务部分 -
postgres:
build: ./postgresql
container_name: postgres
ports:
- '127.0.0.1:5432:5432'
volumes:
- pg-data:/var/lib/postgresql/data
Postgresql
目录有两个文件, dockerfile
和 init.sql
。 Dockerfile
代码 -
FROM postgres:14-alpine
ENV POSTGRES_USER: ...
ENV POSTGRES_PASSWORD: ...
ENV POSTGRES_DB: ...
COPY *.sql /docker-entrypoint-initdb.d/
请帮助如何自定义 Postgres
仅记录关键日志。
I am having hard time in configuring the postgres logging level in Docker. From logging level, what I mean is that say my query is something like - SELECT COUNT(*) FROM tablethatnotexist
then in output returned by the database driver will tell me that in a way - relation "tablethatnotexist" does not exist
.
It's fine until here but getting the same log in the database sometime is just irritating. I mean that I know I queried the databse with that relation which doesn't exist and I also got a response for that. So getting a log like -

doesn't makes any sense and also it just adds up extra logs in the file.
I have searched all around but I just can't found the way to disable the extra logging or just set it to log on the critical errors only since the database driver handles the most errors.
My dev environment -
Docker compose Postgres
service section -
postgres:
build: ./postgresql
container_name: postgres
ports:
- '127.0.0.1:5432:5432'
volumes:
- pg-data:/var/lib/postgresql/data
postgresql
directory has two files, Dockerfile
and init.sql
. Dockerfile
code -
FROM postgres:14-alpine
ENV POSTGRES_USER: ...
ENV POSTGRES_PASSWORD: ...
ENV POSTGRES_DB: ...
COPY *.sql /docker-entrypoint-initdb.d/
Please help on how to customize postgres
to only log the critical logs.
发布评论
评论(1)
如果使用Docker Compose,则可以将此行添加到docker-compose.yaml文件中:
所有查询将写入容器日志文件中。
在官方文档您可以找到详细信息的详细信息
If using Docker Compose, you can add this line to your docker-compose.yaml file:
and all your queries will be written into the container log file.
In the official docs you can find details