Code Monkey home page Code Monkey logo

classic's Introduction

SerilogWeb.Classic

Build status

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

Package - SerilogWeb.Classic | Platforms - .NET 4.5

This package replaces the Serilog.Extras.Web package previously included in the Serilog project.

When you work with an ASP.NET web application, this package adds additional enrichers and an HttpModule to enhance the logging output. The following enrichers are available:

  • HttpRequestId A GUID used to identify requests.
  • HttpRequestNumber an incrementing number per request.
  • HttpRequestTraceId GUID matching the RequestTraceIdentifier assigned by IIS and used throughout ASP.NET/ETW. IIS ETW tracing must be enabled for this to work.
  • HttpSessionId The current ASP.NET session id.
  • UserName The current username or, when anonymous, a defined value. By default this is set to (anonymous).
var log = new LoggerConfiguration()
    .WriteTo.ColoredConsole()
    .Enrich.With<HttpRequestIdEnricher>()
    .Enrich.With<UserNameEnricher>()
    .CreateLogger();

To override the username enricher behaviour:

var log = new LoggerConfiguration()
    .WriteTo.ColoredConsole()
    .Enrich.With(new UserNameEnricher("not known yet", System.Environment.UserName))
    .CreateLogger();

The ApplicationLifecycleModule will automatically be enabled and will write information events about the current method and url that is being accessed. Optionally you also store any form data that is posted to the server. When an unhandled exception occurs, the module will capture it and log it as an error event.

To enable the posting of form data:

ApplicationLifecycleModule.LogPostedFormData = LogPostedFormDataOption.Always;
// or
ApplicationLifecycleModule.LogPostedFormData = LogPostedFormDataOption.OnlyOnError;

Any fields containing the phrase 'password' will be filtered from the logged form data. This can be disabled with ApplicationLifecycleModule.FilterPasswordsInFormData = false.

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

ApplicationLifecycleModule.IsEnabled = false;

classic's People

Contributors

nblumhardt avatar mattgwagner avatar mivano avatar joergbattermann avatar richardlawley avatar simoncropp avatar khellang avatar merbla avatar paulblamire avatar daveaglick avatar ryanande avatar

Watchers

Brendan Kowitz avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.