Frage

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?

War es hilfreich?

Lösung

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top