serilog-web / classic-mvc

[Discontinued] ASP.NET MVC support for SerilogWeb.Classic
Apache License 2.0
10 stars 2 forks source link
asp-net asp-net-mvc serilog serilog-enricher serilog-extension

SerilogWeb.Classic.Mvc Build status

Deprecation notice: this package is no longer maintained. The world has moved on to ASP.NET Core. Take a look at Serilog.AspNetCore instead!

ASP.NET MVC support for SerilogWeb.Classic.

Package - SerilogWeb.Classic.Mvc | 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 ASP.NET MVC specific enrichers.

Enrichers

The following enrichers are available as extension methods from the LoggerConfiguration.Enrich API:

Usage :

var log = new LoggerConfiguration()
    .WriteTo.Console()
    .Enrich.WithMvcRouteTemplate()
    .Enrich.WithMvcActionName()
    .CreateLogger();

To override the property name of the added property:

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

Enrichers can also be defined in a configuration file by using Serilog.Settings.AppSettings as follows:

<appSettings>
    <add key="serilog:using:SerilogWeb.Classic.Mvc" value="SerilogWeb.Classic.Mvc"/>
    <add key="serilog:enrich:WithMvcActionName"/>
    <add key="serilog:enrich:WithMvcControllerName"/>
    <add key="serilog:enrich:WithMvcRouteData"/>
    <add key="serilog:enrich:WithMvcRouteTemplate"/>
</appSettings>