Andrus
Andrus

Reputation: 27955

how to log exceptions in asp .net mvc2 application

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.

Upvotes: 0

Views: 251

Answers (1)

Oded
Oded

Reputation: 499382

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

Upvotes: 4

Related Questions