【发布时间】:2016-09-06 20:09:07
【问题描述】:
我的应用程序出现问题,我的要求之一是在调用 PLPGSQL 函数时捕获 postgres 中输出的消息,类似于此处发生的情况:
Get warning messages through psycopg2
除了我的问题在 npgsql 中。我设置了日志管理器:
NpgsqlLogManager.Provider = new ConsoleLoggingProvider(NpgsqlLogLevel.Trace, true, true);
我打这个电话:
_db.ExecuteScalar("SELECT test_warning();");
test_warning 是一个自定义的 sql 函数:
CREATE OR REPLACE FUNCTION test_warning()
RETURNS void AS
$BODY$
begin
raise info 'this is only a test';
end;
$BODY$
LANGUAGE plpgsql VOLATILE;
而_db 是IDbConnection,并且使用Dapper 进行查询。在我的日志消息中,我只收到了对该函数的调用,以及其他一些连接信息:
DEBUG [40560] Opened connection to (Database Server)
TRACE [40560] Start user action
TRACE [40560] ExecuteNonScalar
DEBUG [40560] Executing statement(s):
SELECT test_warning()
TRACE [40560] End user action
TRACE [40560] Closing connection
TRACE [40560] Really closing connection
DEBUG [40560] Connection closed
没有提及警告/信息消息。
【问题讨论】:
-
Notice Processing 如果您有权访问连接处理程序,那么这很简单。
标签: asp.net-mvc postgresql pgadmin