有log4net内存附加程序吗? [英] Is there a log4net memory appender?

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

问题描述

我正在寻找一种命令行程序能够将其log4net输出通过电子邮件发送给一组用户的方法.现在,我正在读取日志文件,但是我必须调用log4net.LogManager.Shutdown()来释放该文件,以便我可以读取它,而且我必须对日志文件名进行硬编码或为其解析log4net配置.我希望能够配置一个附加的附加程序,该附加程序记录到一个我可以读取的内存位置中.

I'm looking for a way for a command line program to be able to email its log4net output to a group of users. Right now, I'm reading the log file but I have to call log4net.LogManager.Shutdown() to release the file so I can read it, and I have to either hard code the log file name or parse the log4net configuration for it. I'd like to be able to configure an additional appender that logs to an in memory location that I can then read from.

我不介意为此功能创建新的附加程序,但是我不确定最好的选择是什么.我当然不想仅仅依靠另一个文件,数据库或外部数据源来获取我的日志输出.

I don't mind creating a new appender for this functionality, but I'm not sure what the best option is. I certainly don't want to rely on another file, database, or external data source just to get my log output.

推荐答案

是的,有 log4net.Appender.MemoryAppender .它具有 GetEvents() 方法,您可以使用该方法来获取已记录的事件.

Yes, there is log4net.Appender.MemoryAppender. It has a GetEvents() method that you can use to obtain the events that have been logged.

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

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