0

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.

1 Answer 1

4

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).

Sign up to request clarification or add additional context in comments.

3 Comments

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 - 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.
This post by Scott may help: hanselman.com/blog/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.