开发者

Logging Framework for the ASP.NET application

My application needs to log informations about user actions (inserts, updates, deletes, etc) and exceptions and i want to store de log on Oracle10, so i'am searching some log framework to use. I read a little bit about:

1 -Log4Net

2 - Logging Application Block

3 - Elmah

Whats your opinion about these log tools? Whats a good framework (or way to implement) log on my application?

*After a discussion with the project manager,开发者_StackOverflow中文版 Logging Application Block will be our choice, but, lets comment about this =)


Both log4net and Logging Application Block are valid choices. I think ELMAH is mostly focused on error logging, so that is probably not (the only thing) that you want.

At work, I use log4net on a couple of projects. It is stable, performant and extensible, and we have never had any problems with it.

I would probably do logging with log4net and log exceptions with ELMAH also. It can log unhandled exceptions manually, and any exception you catch and handle in your application can be logged with a single call to ELMAH. This might seem like double-logging (and it is :-)). But it is very valuable to have the ELMAH log when something unexpected has failed in your application.

I have heard good things about the NLog project, but haven't used it myself. It seems to be a bit more complex that log4net, but does have the added benefit of being able to add contextual information to log messages automatically (a bit like ELMAH).


My opinions about the different frameworks:

  1. Log4Net - Love it. This is the logging system that I use most often. Everything is fairly easy to get started. It's also very flexible and allows you to log just about anything.

  2. Logging Application Block - Also a good option. I still prefer Log4Net (but the reasons are mostly personal).

  3. Elman - Great for dropping in to an ASP.NET application to log Exceptions. For general message logging though, I would still go with Log4Net.

And I'm guessing based on my opinions what I would suggest you do...

And if not, use Log4Net and create an Adapter you can use in your application to make logging simple.


I personally like BitFactory.Logging because it's lightweight and uses the right amount of abstractions to make the calling code easily testable.

That said, the things you want to log (inserts, updates, deletes) could be logged using only triggers, a solution that might perform better depending on your setup.


I personally always create a wrapper anyway, so I have my own ILog implementation, that works with whichever of these that you choose. This makes it easy to swap in or our implementations.

I tried #2 but it was kind of a pain; #1 would have worked out well for us but we didn't go for it, just went simple custom logging. All I know about #3 is that I know of someone having trouble implementing it in their org. Don't know why, but it actually looks pretty interesting. I don't think you can go wrong with any personally. It partially depends on the API that you like.

HTH.


Log4net is quiet good, it is basically a version of log4j. Elmah is nice also, especially if you find (like me) that you are unable to write to files on the production environment, since it writes to the DB instead. Also, Elmah is more suited for exception logging, and is cool because it allows you to log based on events. In my projects I normaly deploy both log4net and Elmah


If you are auditing data changes in a db then you can use triggers on the relevant table.

For logging in a dotNet app use TraceSource to write logging info and a custom TraceListener to write to a db. Don't need a framework beyond the base class library really.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜