log4 net mutilple日志文件 [英] log4 net mutilple logfiles

查看:111
本文介绍了log4 net mutilple日志文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个用于两个单独日志的滚动文件追加器,第一个RollingLogFileAppender应该将日志存储在catch块中,即异常,第二个Elaspsedtimeappender应该将日志存储在最后一个块中d驱动器,请帮助我,如果可能的话,请使用log4net帮助我如何存储两个catch并最终阻止日志存储在不同文件(仅使用一个滚动文件附加程序的文本)中,请帮助我紧迫. ..........
这是我已在控制器中实现的用于删除操作的代码

i have two rolling file appenders for two seperate logs the first RollingLogFileAppender should store the logs in the catch block ie exceptions and seond Elaspsedtimeappender should store the logs in the finally block the RollingLogFileAppender has path to c drive and Elaspsedtimeappender appender has path to d drive please help me how to do this if possible help me how to store the both catch and finally block logs in different files (text using only one rolling file appender) using log4net please help me its urgent...........
here is the code that i have implemented in controller for delete operation please

employeeModel.EmployeeId = Convert.ToInt32(id);
             employeeService.DeleteEmployee(employeeModel);
         }
     }
     catch (Exception ex)
     {
         **log.ErrorFormat(ex.StackTrace);**
     }
     **finally**
     {
         log.Debug(stopwatch.ElapsedMilliseconds);
     }
     return RedirectToAction("List", "EmployeeMaster");
 }

推荐答案

您需要创建多个记录器.检查SO帖子中的所有答案.
http://stackoverflow.com/questions/1372435/configure-log4net-to-写入多个文件 [ ^ ]
http://stackoverflow.com/questions/308436/log4net-程序化地指定多个记录器与多个文件添加程序 [
You need to create multiple loggers. Check all the answers in SO post.
http://stackoverflow.com/questions/1372435/configure-log4net-to-write-to-multiple-files[^]
http://stackoverflow.com/questions/308436/log4net-programmatically-specify-multiple-loggers-with-multiple-file-appenders[^]


这篇关于log4 net mutilple日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆