我已经在我的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'在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有什么方法可以防止记录这些行吗?
提前感谢
迭戈
发布于 2009-09-16 17:25:02
如果您的应用程序使用自己的角色(应该如此),则只能使用"ALTER ROLE"更改这些角色的相应设置
ALTER ROLE <account> SET log_statement = 'all';(或配置中的"log_min_duration_statement = 0“)。
发布于 2009-09-16 17:21:54
不,从PostgreSQL服务器的角度来看,所有查询都是相等的。这些数据来自某些客户端,服务器无法知道您感兴趣的是哪一个。
最好是对日志文件进行后处理--也许这就像在日志文件上添加"grep“一样简单?
(我假设您希望记录一些查询-如果没有,则需要将log_min_duration_statement设置为-1)
https://stackoverflow.com/questions/1433704
复制相似问题