Oracle样式编号日志记录如何进行? [英] How to do Oracle style numbered logging?
问题描述
在oracle中通常会收到类似-的消息
In oracle one often gets messages like -
ORA-01882: timezone region not found.
此格式具有以下优点-
- 更易于提供电话支持,客户端只需读出错误代码即可.
- 更易于搜索和计算文件中的特定错误.除了使用基于正则表达式的模式匹配搜索日志消息外,我还可以搜索唯一的错误代码.
如何在自己的应用程序中实现此目的?我不仅在询问代码片段,还询问如何管理整个过程.
-
您将在Excel,属性文件或DB中维护错误代码到消息的映射吗?
Would you maintain the mapping of error codes to messages in an Excel, Properties File or DB?
在使用每个代码消息组合之前,是否需要将它们手动输入到DB中?我可以让我的日志记录框架为我记录的每个唯一字符串自动创建一个随机错误代码吗?
Do I need to enter each code-message combo manually into DB before using it? Can I have my logging framework automatically create a random error code for each unique string that I log?
在流行的日志记录框架(如logback)中是否对此有标准规定?
Is there a standard provision for this in popular logging frameworks like logback?
推荐答案
-
需要I18N支持的属性.
Properties if you want I18N support.
代码的特定部分可能存在特定编号错误(如果存在). 例如Apache Derby有一个带有错误消息标识符列表的接口.这是一组消息标识符.
Particular section of code can have a particular number error if exists. e.g. Apache Derby has a interface with a list of error message identifiers. This is the set of message identifiers.
String CONNECT_PASSWORD_ISNULL = "08001.C.8";
String CONNECT_SOCKET_EXCEPTION = "08001.C.3";