使用MSMQ异步日志 [英] Using msmq for asynchronous logging

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

问题描述

我需要做的日志记录在我们的应用程序,并想保持适当消耗的时间记录尽可能少。我想用MSMQ,这样应用程序将登录到MSMQ,然后我可以登录的消息从MSMQ到数据库/异步文件。

I need to do logging in our application and would like to keep the time consumed due to logging as little as possible. I am thinking of using MSMQ so that the application will log into MSMQ and then I can log the messages from MSMQ to the database/files asynchronously.

这种想法在性能方面好?或记录到文件同步使用log4net的是更好的。

Is this idea good in terms of performance? or logging to flat files synchronously using log4net is better.

另外,我编码一个日志抽象层的思想,让我插上任何测井仪器后不影响其他code。

Also , I am thinking of coding a logging abstraction layer so that I plug in any logging tools later without affecting other code.

请指教。

谢谢, sveerap

Thanks, sveerap

推荐答案

我会反对这项建议。这是为不真正存在的问题的不必要的复杂的解决方案。我用log4net的多个项目中,从来没有见过的,因为它的任何显著的性能下降。

I would advise against this. This is a needlessly complex solution for a problem that doesn't really exist. I've used log4net in multiple projects and never saw any significant performance degradation because of it.

这是一个好主意,采取选择合适的日志记录级别为每个日志消息(DEBUG,INFO,WARN,等)照顾得很好。当你在很短的时间开始你的项目,也许当你在制作你登录了从调试到更高的水平。当你有信心一切正常,切换到信息的配置。这应该足以应付可能与日志记录遇到的性能问题。

It's a better idea to take good care of selecting the right logging levels for each log message (DEBUG, INFO, WARN, etc). When you start your project and maybe during a short time when you're in production you log everything from DEBUG to higher levels. When you're confident everything works, you switch to INFO in the configuration. This should be enough to tackle any performance issues you may encounter with logging.

关于你的抽象层,我不会做这样无论是。 log4net的本身抽象通过其记录追加程序的日志文件本身的所有细节。如果你真的想这样,你可能还需要看看 Common.Logging

Concerning your abstraction layer, I wouldn't do this either. Log4net itself abstracts all details of the logging itself via its logger appenders. And if you really want this, you may also want to take a look at Common.Logging.

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

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