github stevejgordon/CorrelationId rel/2.0.0
2.0.0

latest releases: rel/3.0.1, rel/3.0.0, rel/2.1.0...
6 years ago

This major release introduces a key requirement of including a CorrelationContext which makes it possible to access the CorrelationId in classes that don't automatically have access to the HttpContext in order to retrieve the TraceIdentifier.

This is a breaking change since the registration of services in now required. An exception will be thrown if the services are not registered prior to calling the middleware.

Consuming classes can now include a constructor dependency for ICorrelationContextAccessor which will enable the retrieval and use of the current CorrelationContext when performing logging.

Installation

In order to use the 2.0.0 version of this library, the IServiceCollection extension will need to be called in ConfigureServices:

public void ConfigureServices(IServiceCollection services)
{
   services.AddMvc();
   services.AddCorrelationId();
}

The middleware then needs to be added in the Configure method, prior to registering calling UseMvc and any other middleware that you want to have access to the correct CorrelationId. Usually it can be one of the first items registered.

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
   app.UseCorrelationId();

   if (env.IsDevelopment())
   {
	  app.UseDeveloperExceptionPage();
   }

   app.UseMvc();
}

Don't miss a new CorrelationId release

NewReleases is sending notifications on new releases.