Log4net-在AdoNetAppender和RollingFileAppender之间动态切换附加程序 [英] Log4net - dynamically switch appender between AdoNetAppender and RollingFileAppender

查看:112
本文介绍了Log4net-在AdoNetAppender和RollingFileAppender之间动态切换附加程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp.net应用程序中使用AdoNetAppender(SQL服务器),并且如果SQL出现任何连接问题,也想使用RollingFileAppender.有什么方法可以配置为仅在AdoNetAppender出现问题时才使用RollingFileAppender?

I am using AdoNetAppender (SQL server) in my asp.net application and would like use to RollingFileAppender incase of any connection issue with SQL. Is there any way to configure to use RollingFileAppender only when there is an issue with AdoNetAppender?

谢谢

por

推荐答案

log4net中没有对这种故障转移方案的内置支持,问题是在log4net体系结构中,附加程序彼此之间非常隔离.

There is no built in support for this kind of failover scenario in log4net, the problem being that appenders are quite isolated from each other in the log4net architecture.

尽管常见的设置是让两个追加程序并行记录,只是文件追加程序只能保存例如一周的数据.如果AdoNetAppender失败,您将始终在文件中拥有最新数据.

A common setup though is to have both appenders logging in parallel, only that the file appender only keeps, say, a weeks worth of data. Should the AdoNetAppender fail you will always have the latest data in files.

但是我在这里肯定地看到了一个追加器的情况,该追加器可以具有子追加器的优先级列表,以在出现故障时进行一些简单的故障转移.在 AppenderSkeleton .

But I definitively see the case here for an appender that could have a priority list of sub-appenders doing some simple failover in case of failure. This should not be too hard to implement either building on the AppenderSkeleton.

这篇关于Log4net-在AdoNetAppender和RollingFileAppender之间动态切换附加程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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