使用MSMQ异步日志日志、MSMQ

2023-09-04 11:57:03 作者:风蓅Иé尙

我需要做的日志记录在我们的应用程序,并想保持适当消耗的时间记录尽可能少。我想用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.

 
精彩推荐
图片推荐