Code Monkey home page Code Monkey logo

classic-mvc's Introduction

SerilogWeb.Classic.Mvc Build status

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:

  • WithMvcActionName : adds a property MvcAction containing the name of the Action being executed in the MVC Controller
  • WithMvcControllerName : adds a property MvcController containing the name of the Controller in which a MVC Action has executed
  • WithMvcRouteData : adds a property MvcRouteData containing the dictionary of the RouteData
  • WithMvcRouteTemplate : adds a property MvcRouteTemplate containing the route template selected by Mvc routing

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>

classic-mvc's People

Contributors

dgarciarubio avatar nblumhardt avatar tsimbalar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

classic-mvc's Issues

Properly publish nuget package

Add a nuspec file, inspired from https://github.com/serilog-web/classic-webapi/blob/master/src/SerilogWeb.Classic.WebApi/SerilogWeb.Classic.WebApi.nuspec to avoid warnings when publishing package :

Packing files from 'C:\projects\classic-mvc\src\SerilogWeb.Classic.Mvc\bin\Release'.
Found packages.config. Using packages listed as dependencies
WARNING: Description was not specified. Using 'Description'.
WARNING: Author was not specified. Using 'appveyor'.
Successfully created package 'C:\projects\classic-mvc\SerilogWeb.Classic.Mvc.0.1.3.nupkg'.
Attempting to build symbols package for 'SerilogWeb.Classic.Mvc.csproj'.
Packing files from 'C:\projects\classic-mvc\src\SerilogWeb.Classic.Mvc\bin\Release'.
Found packages.config. Using packages listed as dependencies
WARNING: Description was not specified. Using 'Description'.
WARNING: Author was not specified. Using 'appveyor'.
Successfully created package 'C:\projects\classic-mvc\SerilogWeb.Classic.Mvc.0.1.3.symbols.nupkg'.
Discovering tests...OK
Collecting artifacts...

Complete the README

Add :

  • description of project
  • reminder that it is not for ASP.NET Core projects
  • relationship with SerilogWeb.Classic and SerilogWeb.Classic.WebApi
  • links to nuget / appveyor etc
  • details about the included enrichers and their behavior

AppVeyor build is broken

Looks pretty similar to serilog-web/classic-webapi#6 ...

Classic\Mvc\Enrichers\BaseMvcContextInfoEnricher.cs(22,51): error CS1525: Invalid expression term 'throw' [C:\projects\classic-mvc\src\SerilogWeb.Classic.Mvc\SerilogWeb.Classic.Mvc.csproj]
Classic\Mvc\Enrichers\BaseMvcContextInfoEnricher.cs(22,51): error CS1002: ; expected [C:\projects\classic-mvc\src\SerilogWeb.Classic.Mvc\SerilogWeb.Classic.Mvc.csproj]
Attempting to build package from 'SerilogWeb.Classic.Mvc.csproj'.
MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin\amd64'.
The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Unable to find 'C:\projects\classic-mvc\src\SerilogWeb.Classic.Mvc\bin\Release\SerilogWeb.Classic.Mvc.dll'. Make sure the project has been built.

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.