在postgres 9.1中触发触发器的日志 [英] Log firing of triggers in postgres 9.1

查看:83
本文介绍了在postgres 9.1中触发触发器的日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个数据库,该数据库在数据库内部的触发器中存储了大量的业务逻辑.有没有一种方法可以记录触发器的触发以及触发的参数以及更改的内容?

我看了很多关于如何使用触发器进行表审计的教程,但是我想审计触发器而不是表:)

解决方案

以使用触发器进行表审核的示例之一为例.使用他们的方法来提取更改的数据,但不要将数据写入审核表中,而应将其用于 RAISE NOTICE .

如果您正确设置日志记录配置,该通知将被写入PostgreSQL日志文件( log_min_messages = notice )

有关RAISE的详细信息,请参见手册: http://www.postgresql.org/docs/current/static/plpgsql-errors-and-messages.html

We have DB that has massive amount of business logic stored in triggers inside DB. Is there a way to log firing of triggers along with arguments that they have been fired, and what they have changed?

I saw a lot of tutorials on how to do table audit with triggers, but I would like to audit triggers not tables :)

解决方案

Take one of the examples that do table auditing with triggers. Use their approach to extract the changed data, but do not write the data into an audit table, but use it for a RAISE NOTICE.

That notice will then be written to the PostgreSQL log file if you set the logging configuration correctly (log_min_messages = notice)

See the manual for details on RAISE: http://www.postgresql.org/docs/current/static/plpgsql-errors-and-messages.html

这篇关于在postgres 9.1中触发触发器的日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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