带有多个附加程序的log4net [英] log4net with multiple appender

查看:121
本文介绍了带有多个附加程序的log4net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我需要为两种类型的附加程序自定义log4net,一种是文件,另一种是adoNet.如果与sql的连接出现问题,我们将记录到文件,否则它将记录到日志表中的数据库.
如果有人从事类似的工作,请帮帮我.

谢谢.

Hi all

I need to customized log4net for two type of appender one is file and other is adoNet.We will log to file if we there is problem with connection with sql other wise it will log to database in the log table.

Please help me if somebody work in similar concept.

Thanks.

推荐答案

您要查找的内容当前在log4net中不存在,但已将其输入为要实现的功能.有关更多信息,请参见此处.

您可以执行此操作的另一种方法是获取 AdoNetAppender FileAppender 的源并将它们合并为自定义附加程序类型.

创建新的附加程序并不困难,唯一需要的新代码就是检查数据库连接是否可用.如果没有,请使用文件附加器.

有关创建附加程序的更多信息,请参见文章

希望对您有帮助
What you are looking for doesn''t currently exist in log4net, but it has been entered as a feature to be implemented. See here for more info.

Another way you could do this is by taking the source of the AdoNetAppender and FileAppender and merge them into a custom appender type.

Creating new appenders isn''t difficult and the only new code required would be to check to see if the DB connection is available. If not, use the file appender.

For more info on creating appenders, see this article

Hope this helps


这篇关于带有多个附加程序的log4net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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