简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM