MindingData
MindingData

Reputation: 12470

Application Insights logs "no data for server exceptions"

I had an issue on my test server that was throwing an exception, I noticed that it logged nothing to application insights so first tried to debug on my local machine. I managed to replicate the issue, and low and behold in my DEV application insights I have server exceptions logged.

enter image description here

So I go back to my Test Application insights and again replicate the issue but still no errors logged (Even after an hour or so).

enter image description here

However I can see it logs them as "Failed Requests", just not Server Exceptions. Without the server exceptions I can't see the stacktrace/error message.

enter image description here

I am using the Log4Net app insights extension to log these exceptions. It's obviously not a code issue because the same code is being run in both cases. So I looked at configuration issues.

Upvotes: 0

Views: 429

Answers (1)

MindingData
MindingData

Reputation: 12470

Here's the answer (Kinda)

I was logging the exception in a Basecontroller, this worked fine on my local machine and I could debug through.

What happens though is when I push it remotely, .net's out of the box error handling kicks in. Notably the global "HandleErrorAttribute" (Check your FilterConfig.cs). This seems to capture and swallow the exception. There is lots of other talks about this if you wish to override this behaviour, mostly when talking about other logging tools like Elmah.

The reason I only see this in my test environment is because CustomErrors defaults to remoteOnly. So I only see it not logging when it's not on my machine.

Because I'm handling errors myself, I can remove this line from my FilterConfig.cs

filters.Add(new HandleErrorAttribute());

And server exceptions should be logged now (I also handle showing the user a nice error page in my BaseController for now)

Upvotes: 0

Related Questions