Skip to content
This repository was archived by the owner on Oct 2, 2024. It is now read-only.

serilog-web/classic-webapi

Repository files navigation

SerilogWeb.Classic.WebApi Build status

ASP.NET WebAPI support for SerilogWeb.Classic.

Package - SerilogWeb.Classic.WebApi | Platforms - .NET 4.5

This package is designed for full framework ASP.NET applications. For ASP.NET Core, have a look at Serilog.AspNetCore

This package is used in conjunction with SerilogWeb.Classic and adds :

  • support for logging WebAPI exceptions with Serilog
  • Web API specific enrichers

Enrichers

The following enrichers are available in the SerilogWeb.Classic.WebApi.Enrichers namespace:

  • WebApiActionNameEnricher : adds a property WebApiAction containing the name of the Action being executed in the Web API Controller
  • WebApiControllerNameEnricher : adds a property WebApiController containing the name of the Controller in which a Web API Action has executed
  • WebApiRouteDataEnricher : adds a property WebApiRouteData containing the dictionary of the RouteData
  • WebApiRouteTemplateEnricher : adds a property WebApiRouteTemplate containing the route template selected by Web API routing

Usage :

var log = new LoggerConfiguration() .WriteTo.Console() .Enrich.With<WebApiRouteTemplateEnricher>() .Enrich.With<WebApiActionNameEnricher>() .CreateLogger();

To override the property name of the added property:

var log = new LoggerConfiguration() .WriteTo.Console() .Enrich.With(new WebApiRouteTemplateEnricher("RouteTemplate") .CreateLogger();

About

[Discontinued] ASP.NET WebAPI support for SerilogWeb.Classic

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •