1
我遇到了一个与我的应用程序有关的问题,我的一个要求是捕获postgres中输出的消息,当我调用PLPGSQL函数时,与此处发生的情况类似:通过npgsql获取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
警告/信息消息没有提及。
[注意信息处理(https://www.postgresql.org/ docs/current/static/libpq-notice-processing.html)如果您有权访问连接处理程序,那么它很简单。 – Abelisto