为Log4Net添加异常处理模块
2007-11-13 09:02
148 查看
Log4Net默认是不抛出任何异常的。也就是说,如果写Log的时候出现错误,系统也不会停止,只是不会写入。但此时,更多的情况是需要通知系统管理员,这就需要我们自己写一个exception handler来处理,
1。在log4net.config中加入
<appender>
<errorHandler type="classname, assemblyname" />
</appender>
2.实现IErrorHandler 接口
public class LogExceptionHandler : IErrorHandler
{
public void Error(string message, Exception e, ErrorCode errorCode)...
public void Error(string message, Exception e)...
public void Error(string message)...
}
这样就可以了,扩展起来真的很容易,佩服设计人员的水准,呵呵。
1。在log4net.config中加入
<appender>
<errorHandler type="classname, assemblyname" />
</appender>
2.实现IErrorHandler 接口
public class LogExceptionHandler : IErrorHandler
{
public void Error(string message, Exception e, ErrorCode errorCode)...
public void Error(string message, Exception e)...
public void Error(string message)...
}
这样就可以了,扩展起来真的很容易,佩服设计人员的水准,呵呵。
相关文章推荐
- 为Log4Net添加异常处理模块 [转贴]
- 一个模块如何处理异常
- 把WCF服务部署服务器IIS异常(详细:处理程序“svc-Integrated”在其模块列表中有一个错误模块“ManagedPipelineHandler”)
- C语言异常处理机制——为您的C程序添加异常处理
- 解析Node.js异常处理中domain模块的使用方法
- vc2010中添加动态链接库的方式,在多模块、业务分层过程中的处理方式
- 系统中异常公共处理模块 in spring boot
- PYTHON 异常处理 二 TRY 模块
- .net生成日志处理,记录产生,异常的模块,进程号,线程号:
- 解决"System.AccessViolationException”类型的未经处理的异常在 未知模块(IIS Worker Process 已停止工作)导致无法连接远程数据库的问题
- 用c++ try-catch 异常处理模块实现SEH底层异常处理。
- PHP错误和异常处理功能模块示例
- Node.js 异步异常的处理与domain模块解析
- python进阶(8):常用模块2+异常处理
- 一个模块如何处理异常
- spring mvc 异常处理和session添加
- “System.AccessViolationException”类型的未经处理的异常在 未知模块。
- Python之异常处理、模块与包