仅记录Postgres中的用户查询

Die*_*ego 5 postgresql logging

我在Postgres数据库中启用了日志记录(在Ubuntu 32位上运行),我只想记录用户应用程序执行的查询.我配置了postgres如下:

log_destination = 'syslog'
syslog_facility = 'L*emphasized text*OCAL0'
syslog_ident = 'postgres'
log_min_messages = notice
log_min_duration_statement = 0
log_duration = off
log_line_prefix = 'user=%u,db=%d '
log_statement = 'none'
Run Code Online (Sandbox Code Playgroud)

syslog.conf我已经配置为每个日志local0被重定向到/var/log/pgsql.

但是,Postgres记录了很多我不关心的查询,例如:

WHEN typbasetype=0 THEN oid else typbasetype END AS
Sep 16 12:22:28 or-ubuntu postgres[14086]: [11-2]  basetype
Sep 16 12:22:28 or-ubuntu postgres[14086]: [11-3] ^I  FROM pg_type WHERE oid=1043
Sep 16 12:22:28 or-ubuntu postgres[14086]: [12-1] user=postgres,db=prueba LOG:  duración: 0.361 ms sentencia: SELECT format_type(oid,-1) as typname FROM pg_type WHERE oid = 2950
Sep 16 12:22:28 or-ubuntu postgres[14086]: [13-1] user=postgres,db=prueba LOG:  duración: 0.348 ms sentencia: SELECT CASE WHEN typbasetype=0 THEN oid else typbasetype END AS
Sep 16 12:22:28 or-ubuntu postgres[14086]: [13-2]  basetype
Sep 16 12:22:28 or-ubuntu postgres[14086]: [13-3] ^I  FROM pg_type WHERE oid=2950
Sep 16 12:22:28 or-ubuntu postgres[14086]: [14-1] user=postgres,db=prueba LOG:  duración: 0.451 ms sentencia: SELECT format_type(oid,104) as typname FROM pg_type WHERE oid =
Sep 16 12:22:28 or-ubuntu postgres[14086]: [14-2]  1043
Sep 16 12:22:28 or-ubuntu postgres[14086]: [15-1] user=postgres,db=prueba LOG:  duración: 0.353 ms sentencia: SELECT CASE WHEN typbasetype=0 THEN oid else typbasetype END AS
Sep 16 12:22:28 or-ubuntu postgres[14086]: [15-2]  basetype
Sep 16 12:22:28 or-ubuntu postgres[14086]: [15-3] ^I  FROM pg_type WHERE oid=1043
Run Code Online (Sandbox Code Playgroud)

有没有办法阻止这些行被记录?

提前致谢

迭戈

Mil*_*dev 5

如果您的应用程序使用自己的角色(应该如此),则只能使用"ALTER ROLE"更改这些角色的相应设置:

ALTER ROLE <account> SET log_statement = 'all';
Run Code Online (Sandbox Code Playgroud)

(或配置中的"log_min_duration_statement = 0").