12

I read about Web API having its own TraceWriter implementation with 2012.2, for example here, among other sources.

I am now using VS2013 with .NET 4.5.1 and the EnableSystemDiagnosticsTracing is nowhere to be found. It's meant to be defined in the HttpConfigurationTracingExtensions class which resides in the System.Web.Http.Tracing.dll. However, this assembly is nowhere to be found - not in list of assemblies in the Add Reference dialog, not in GAC.

Where is this assembly supposed to come from? Docs say it's part of .NET Framework 4, which I have installed. Also installed the ASP.NET Web API 2 Tracing 5.0.0 NuGet package. Is there some update? Should I re-install .NET Framework?

I know it's not a big deal to implement ITraceWriter myself but it bothers me not to know what happened with the built-in implementation.

Kara
  • 6,115
  • 16
  • 50
  • 57
Vroomfundel
  • 730
  • 7
  • 24

2 Answers2

13

Just install needed NuGet Package

Install-Package Microsoft.AspNet.WebApi.Tracing -Version 5.0.0

It's a little bit strange, but it is the right package

http://www.nuget.org/packages/microsoft.aspnet.webapi.tracing

Regfor
  • 8,515
  • 1
  • 38
  • 51
6

If you installed the Tracing 5.0.0 NuGet package, it should be correctly included in your project. The moment it is installed, I believe a separate text file should open in VS showing the code you should include in your WebApiConfig.cs file.

I haven't created a Web API 2 project from scratch (only upgraded from pre-5.0 to 5.0 projects), but this is the code that should reside in your WebApiConfig.cs file:

// To disable tracing in your application, please comment out or remove the following line of code
// For more information, refer to: http://www.asp.net/web-api
config.EnableSystemDiagnosticsTracing();

And that should be it, if the package is installed correctly, tracing should now be used in your project.

Kazu
  • 627
  • 6
  • 17