SerilogWeb.Classic 5.1.66

dotnet add package SerilogWeb.Classic --version 5.1.66
NuGet\Install-Package SerilogWeb.Classic -Version 5.1.66
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SerilogWeb.Classic" Version="5.1.66" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SerilogWeb.Classic --version 5.1.66
#r "nuget: SerilogWeb.Classic, 5.1.66"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SerilogWeb.Classic as a Cake Addin
#addin nuget:?package=SerilogWeb.Classic&version=5.1.66

// Install SerilogWeb.Classic as a Cake Tool
#tool nuget:?package=SerilogWeb.Classic&version=5.1.66

Web request logging and enrichment for classic ASP.NET applications (System.Web).

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

When you work with an ASP.NET web application, this package adds

  • additional enrichers
  • an HttpModule to enhance the logging output.

When working with ASP.NET MVC (not Core) or ASP.NET Web API, you may also want to have a look at SerilogWeb.Classic.Mvc and SerilogWeb.Classic.WebAPI


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

  • WithClaimValue : adds a property contaning the value of a given claim from the current ClaimsIdentity User
  • WithHttpRequestClientHostIP : adds a property HttpRequestClientHostIP containing Request.UserHostAddress (optionally checking for proxy header)
  • WithHttpRequestClientHostName : adds a property HttpRequestClientHostName containing Request.UserHostName
  • WithHttpRequestId : adds a property HttpRequestId with a GUID used to identify requests.
  • WithHttpRequestNumber : adds a property HttpRequestNumber with an incrementing number per request.
  • WithHttpRequestRawUrl : adds a property HttpRequestRawUrl with the Raw Url of the Request.
  • WithHttpRequestTraceId : adds a property HttpRequestTraceId with a GUID matching the RequestTraceIdentifier assigned by IIS and used throughout ASP.NET/ETW. (IIS ETW tracing must be enabled for this to work)
  • WithHttpRequestType : adds a property HttpRequestType with the Request Type (GET or POST).
  • WithHttpRequestUrl : adds a property HttpRequestUrl with the Url of the Request.
  • WithHttpRequestUrlReferrer : adds a property HttpRequestUrlReferrer with the UrlReferrer of the Request.
  • WithHttpRequestUserAgent : adds a property HttpRequestUserAgent with the User Agent of the Request.
  • WithHttpSessionId : adds a property HttpSessionId with the current ASP.NET session id.
  • WithUserName : adds a property UserName with the current username or, when anonymous, a defined value. By default this is set to (anonymous).
var log = new LoggerConfiguration()

To override the username enricher behaviour:

var log = new LoggerConfiguration()
    .Enrich.WithUserName("not known yet", System.Environment.UserName)

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

    <add key="serilog:using:SerilogWeb.Classic" value="SerilogWeb.Classic"/>
    <add key="serilog:enrich:WithClaimValue.claimProperty" value="MyClaimPropertyName"/>
    <add key="serilog:enrich:WithHttpRequestClientHostIP"/>
    <add key="serilog:enrich:WithHttpRequestClientHostName"/>
    <add key="serilog:enrich:WithHttpRequestId"/>
    <add key="serilog:enrich:WithHttpRequestNumber"/>
    <add key="serilog:enrich:WithHttpRequestRawUrl"/>
    <add key="serilog:enrich:WithHttpRequestTraceId"/>
    <add key="serilog:enrich:WithHttpRequestType"/>
    <add key="serilog:enrich:WithHttpRequestUrl"/>
    <add key="serilog:enrich:WithHttpRequestUrlReferrer"/>
    <add key="serilog:enrich:WithHttpRequestUserAgent"/>
    <add key="serilog:enrich:WithHttpSessionId"/>
    <add key="serilog:enrich:WithUserName"/>


The ApplicationLifecycleModule Http module is automatically hooked up into your ASP.NET application as soon as you install the SerilogWeb.Classic package.

For each HTTP request that hits your application, this module will write log events containing information such as :

  • Url
  • Http Method
  • Response status code
  • Processing time

Regular events are written at Information level, and unhandled exceptions are captured and written at the Error level.

Optionally, form data that is posted to the server can also be captured.

The behavior of the Http module should fit most needs by default, but can be customized for finer control.

Fluent Configuration API

SerilogWeb.Classic v4.1 introduced a new fluent configuration API that is more discoverable and easier to test. The previous configuration mechanisms are still supported, but are considered obsolete and will be removed in a future major version.

All the configuration is done through method calls on SerilogWebClassic.Configure(cfg =>

By default, all requests will be logged at the Information level. To change this (i.e. to generate less events under normal conditions) use the LogAtLevel() method:

SerilogWebClassic.Configure(cfg => cfg

(new in v5.1) If you want even more control, you can pass a callback to .LogAtLevel() and provide a Func<HttpContextBase, TimeSpan, LogEventLevel> like this :

SerilogWebClassic.Configure(cfg => cfg
  .LogAtLevel((context, elapsed) => elapsed.TotalMilliseconds > 3000 ? LogEventLevel.Warning : LogEventLevel.Information)

To enable the capture of posted form data:

SerilogWebClassic.Configure(cfg => cfg
// or
SerilogWebClassic.Configure(cfg => cfg
  .EnableFormDataLogging(forms => forms
// or
SerilogWebClassic.Configure(cfg => cfg.
  .EnableFormDataLogging(forms => forms
    .OnMatch(ctx => !ctx.Request.Url.PathAndQuery.StartsWith("/__browserLink"))

Any fields containing the phrase 'password' will be filtered from the logged form data. This can be disabled with:

SerilogWebClassic.Configure(cfg => cfg
  .EnableFormDataLogging(forms => forms

If you want to disable the logging completely, use the following statement:

SerilogWebClassic.Configure(cfg => cfg

The configuration method calls are chainable, so a full configuration may look like :

SerilogWebClassic.Configure(cfg => cfg
  .IgnoreRequestsMatching(ctx => !ctx.Request.IsAuthenticated)
  .EnableFormDataLogging(forms => forms
    .FilterKeywords(new[] {"password", "authToken"} )
Product Compatible and additional computed target framework versions.
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on SerilogWeb.Classic:

Package Downloads

Adds WebAPI exception logging to SerilogWeb.Classic


Adds ASP.NET MVC enrichers to SerilogWeb.Classic

Serilog.Extras.Web The ID prefix of this package has been reserved for one of the owners of this package by

Obsolete. Please install SerilogWeb.Classic.


Offers buffered logging to Serilog to only write to the log upon a specific log level. The web version automatically buffers based on the HTTP Request Id.


A starter kit to quickly add Serilog/AppInisghts/Operations based diagnostics to an episerver application.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
5.1.66 833,300 4/20/2021
5.0.61 758,122 4/22/2020
5.0.58 2,529 4/21/2020
5.0.56 162,289 2/26/2020
5.0.52 656,317 4/4/2019
5.0.48 299,568 2/28/2019
4.2.42 567,688 5/29/2018
4.2.41 25,570 5/24/2018
4.1.38 17,987 5/22/2018
4.0.30 180,686 3/12/2018
3.0.24 28,600 2/10/2018
3.0.20 505,963 10/11/2017
3.0.19 2,775 10/11/2017
2.1.17 182,417 6/13/2017
2.1.15 27,000 5/17/2017
2.1.13 29,379 4/7/2017
2.0.12 2,174 4/7/2017
2.0.10 175,580 9/23/2016
2.0.9 134,755 2/16/2016
2.0.8 1,985 2/16/2016
2.0.7 1,976 2/16/2016
2.0.6 34,370 9/29/2015
2.0.5 16,396 8/18/2015
2.0.4 13,632 8/14/2015
2.0.3 25,910 7/12/2015
2.0.2 17,143 6/15/2015
2.0.1 2,818 9/23/2016
1.0.1 36,554 4/7/2015