Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Sometimes exceptions occur in my ASP .NET MVC 2 application. ASP .NET shows standard error page to user. Programmer doesnt have any information that such exception occurs.

How to log those exceptions to application log table in PostgreSql database. There is table logfile in PostgreSql database where application writes log info. How to catch those exceptions and write to log file. It is ok to show asp .net standard error page to user but exceptions needs to be logged also. Only if excepton occurs during exception logging, exception should not logged.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

I suggest using ELMAH for logging uncaught exceptions.

There are nuget packages for it - certainly for SQL Server, though it shouldn't be difficult to use that as a base to log to postgres if there isn't a package already.

Update: found this (ELMAH on PostgreSQL).

share|improve this answer
    
Thank you. ELMAH looks too heavy. Only logging is required. Is Application_error override best for this ? How to retrieve stack trace and other error information ? –  Andrus Nov 11 '12 at 21:10
1  
@Andrus - Too heavy? That's pretty much all it does - logging and displaying logs (unless you don't look at your logs). You seem to be dismissing it out of hand - it is a widely used solution. –  Oded Nov 11 '12 at 21:11
    
This post by Scott may help: hanselman.com/blog/… –  Mightymuke Nov 12 '12 at 0:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.