Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using msmq for asynchronous logging

Tags:

c#

.net

logging

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.

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

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

Please advise.

Thanks, sveerap

like image 625
sveerap Avatar asked Feb 16 '11 07:02

sveerap


1 Answers

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.

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.

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.

like image 183
Ronald Wildenberg Avatar answered Oct 11 '22 08:10

Ronald Wildenberg