如果数据库已关闭,请将log4net日志记录在文件中 [英] Log the log4net logs in file if the database is down

查看:59
本文介绍了如果数据库已关闭,请将log4net日志记录在文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有办法配置log4net是这样一种方式,如果数据库关闭或无法连接到数据库异常应该登录到文件(仅当数据库有问题时)。目前我可以为数据库和文件编写。



我尝试过:



目前我可以为数据库和文件写入。

Is there way to configure the log4net is such a way that, if the database is down or could not able to connect to database exceptions should log into file(only if the database is having problem). Currently i am able to write for both database and file.

What I have tried:

Currently i am able to write for both database and file.

推荐答案

您可以尝试以编程方式更改配置,但这似乎不这是一个很容易实现的壮举,这里有一些例子:



David's Weblog»在运行时以编程方式更改log4net阈值和级别 [ ^ ]



以编程方式更改log4net日志记录级别 - Nishant Rana的Weblog [ ^ ]
You could try to change the configuration programmatically, but this does not seem to be an easy feat to accomplish, here are some examples:

David's Weblog » Changing log4net threshold and levels programmatically during runtime[^]

Change log4net logging level programmatically – Nishant Rana's Weblog[^]


这篇关于如果数据库已关闭,请将log4net日志记录在文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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