3

Background

I'm troubleshooting some issues with a .NET Web API 2 service. The issues are inconsistent, and from the requesting service, all we see are Connection Resets and Socket Exceptions. It is not even hitting the User Code/logging in the API, but for low level exceptions that doesn't rule the WEB API out as the culprit.

Research

A very useful tool in the past for troubleshooting similar issues in WCF was enabling WCF Tracing. I'm looking for an equivalent that can show the low level Service Trace for the Web API.

I've found Global Error Handling and I've used packages like Elmah in the past. but to my knowledge this only shows unhandled exceptions, as opposed to the entire trace of the Service like the svclog does.

I also know about Fiddler and Wireshark, and while these are excellent tools for http tracking and low level protocol sniffing. At this point, I'm interested more in what the .NET service thinks it's receiving and how it's processing those actions, rather than if packets are making it over the wire.

Summary

Is there an equivalent for Web API 2 to WCF .svclog? With particular focus on the low level service interactions with bytes/requests.

Edit

I have accepted the best answer, both answers pointed to the same form of tracing. It's worth mentioning, that for this specific issue the tracing did not show any additional information, however I do believe it is the closest tracing Web API has to WCF svclog.

Community
  • 1
  • 1
Mabdullah
  • 1,013
  • 6
  • 26

2 Answers2

2

There is no direct equivalent solution in WebAPI but they have added some tracing capabilities in V2. You can refer to the article below.

Tracing in ASP.NET Web API 2

If you have connection issues, I would also check the IIS logs and the httperr logs that may give you more details on such issues.

Julien Jacobs
  • 2,561
  • 1
  • 24
  • 34
  • Good link, I'll set that up and see if it's capturing any information on these failed requests. good point on the IIS logs btw. I'll test out the tracing and get back to you guys on how it compares. – Mabdullah Nov 17 '14 at 14:30
2

WCF and WebAPI are night and day different. WCF has a complex messaging infrastructure, with lots of middleware that requires the level of tracing they supply to troubleshoot.

WebAPI on the other hand is quite simple, and there is very little that sits between the request itself and your code. Any problem in that code presents itself as YSOD (ie a 500 error, which if custom errors are disabled will show the exception). Just like an MVC or even standard ASP.NET application.

Now, there is some tracing available, but it is not to svclog's like with WCF. There is information here:

http://blogs.msdn.com/b/roncain/archive/2012/04/12/tracing-in-asp-net-web-api.aspx

You will have to write your own logger, although maybe there are some loggers out there you can find already.

Erik Funkenbusch
  • 92,674
  • 28
  • 195
  • 291
  • Based on the question, it looks like the code is not even reached so not sure a logger would help much. If I misunderstood, there some existing loggers @ https://github.com/WebApiContrib/WebAPIContrib/blob/master/readme.md If you want to write your own logger, you can that their implementation as an example – Julien Jacobs Nov 16 '14 at 19:58
  • fair point, the trace info, is not quite as low level, but may still be useful, for what I'm looking for. Unfortunately we're not even getting to the point where the API is returning a 500, but hopefully these traces will indicate if the request hits the Web API at all during these failures. Thanks. – Mabdullah Nov 17 '14 at 14:28