Can I log errors to a database or external service within `Global.asax`?

Responsive Ad Header

Question

Grade: Education Subject: Support
Can I log errors to a database or external service within `Global.asax`?
Asked by:
72 Viewed 72 Answers

Answer (72)

Best Answer
(437)
Yes, you can log errors to a database or external service from the `Application_Error` event handler in `Global.asax`. You would use a logging library (e.g., Serilog, NLog) or write code to connect to a database and store the error details (type, message, stack trace, user context, timestamp) for later analysis and debugging. Sending error notifications to a monitoring service like Sentry or Azure Application Insights is also common.