0

I am trying to use ELMAH for error logging in my ASP.NET MVC application. I installed the ELMAH.MVC package from NuGet Packaage Manager. I think I understand the basics of ELMAH, after having gone through a lot of online resources.

I am trying to implement a custom logger that will log specific details about the error into specific columns of a table in my database. I can't use the inbuilt SqlErrorLog because it has some constraints which I cannot accommodate, like having tables and stored procedures with specific names. Hence, I wrote my own custom logger, deriving from SqlErrorLog.

The problem is, I don't know what to do inside the three methods that I need to override - GetError, GetErrors and Log. Sure, the name gives some idea, but I need more specifics. For example, why is the return value of Log string? What do I need to return?

Surprisingly, the assembly is devoid of any documentation, and I have had no luck whilst attempting to look for detailed documentation on the internet.

Can someone point me to a resource such as the detailed documentation of all the classes/methods in ELMAH, or maybe a sample custom logger implementation with comments?

Bhushan Shah
  • 1,028
  • 8
  • 20
  • I wrote some documentation on exactly that: [Writing custom error loggers for ELMAH](http://blog.elmah.io/writing-custom-error-loggers-for-elmah/). – ThomasArdal Sep 06 '16 at 04:49

1 Answers1

2

I would recommend searching the google group site for answers and hints.

The official site: https://code.google.com/p/elmah/ The site is lacking clear documentation for what you are looking for.

Google Group: https://groups.google.com/forum/#!searchin/elmah/sqlerrorlog%7Csort:date

The next link advises you to overwrite the sql procs and is probably a lot easier to implement then overriding the sqlerrorlog methods. https://groups.google.com/forum/#!searchin/elmah/override$20sqlerrorlog/elmah/2foh2FTmHGI/GqDAza-MqbQJ

If you choose to override the methods, I would look at the source for the class here. https://code.google.com/p/elmah/source/browse/src/Elmah.SqlServer/SqlErrorLog.cs

Bill
  • 2,382
  • 2
  • 24
  • 27