0

我是卡纳加拉杰。在我们的存储过程中,我们在 500 个位置记录消息,并且日志存储在我们遇到一些性能问题的表中。我们需要将这些消息拆分为 Debug、Info 和 Error 消息。根据级别,只应记录有限的消息。如有必要,我们将启用下一个级别并查看更多日志。在我们的程序中引入这种基于级别的日志记录的有效方法是什么?

提前致谢。

卡纳加拉杰。

4

4 回答 4

4

像这样的东西...

create or replace package logger as
  min_level number := 2;
  procedure ins_log(level number, message varchar2);
end;

create or replace package body logger as
  procedure ins_log(level number, message varchar2) is
    pragma autonomous_transaction;
  begin
    if level>=min_level then
      insert into loggin(ts, msg) values (sysdate, message);
    end if;
    commit; // autonomous_transaction requires that
  end;
end;

编辑:添加pragma autonomous_transaction;,谢谢亚当

于 2010-09-22T10:13:50.183 回答
2

可以在sourceforge上找到用于 Oracle PL/SQL 的 log4j 端口。这允许在各个级别启用/禁用日志记录,并且对于特定的包/功能/过程只需修改配置。它还支持重定向到不同的目的地。

于 2010-09-22T12:39:57.273 回答
1

有点晚了;我建议您使用 Logger:https ://github.com/tmuth/Logger---A-PL-SQL-Logging-Utility它会处理您的要求。

于 2013-08-09T19:59:29.670 回答
0

在https://sourceforge.net/p/plj-logger/home/查看 PLJ-Logger 。它真的很容易实现,并且具有您想要的功能等等。内置在 PL/SQL 代码中的正确日志记录将对其进行转换。

于 2010-10-10T15:43:10.423 回答