Coder Social home page Coder Social logo

serilog-sinks-log4net's Introduction

Serilog.Sinks.Log4Net

Build status NuGet Version

Duplicates Serilog events through the log4net pipeline to allow integration with existing code and libraries.

Package - Serilog.Sinks.Log4Net | Platforms - .NET 4.5

var log = new LoggerConfiguration()
    .WriteTo.Log4Net()
    .CreateLogger();

Context Message Marker

Passing true for supplyContextMessage, will add a context message of Serilog-Log4NetSink scoped just for the log call under the NDC stack, which you can utilise for Log4Net filters and other purposes. See Log4Net documentation.

e.g.

var log = new LoggerConfiguration()
    .WriteTo.Log4Net(supplyContextMessage: true)
    .CreateLogger();

This can let you specify a filter on an appender in Log4Net. The example below, disables the Seq appender for Log4Net if the context message is present. Useful to stop doubling up logs, for when you have Log4Net and Serilog both pushing to the same sink during migration of logging practices.

<log4net>
  <appender name="TraceAppender" type="log4net.Appender.TraceAppender">
    <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%newline%-5level %logger %newline - %message" />
    </layout>
  </appender>
  <appender name="SeqAppender" type="Seq.Client.Log4Net.SeqAppender, Seq.Client.Log4Net">
    <filter type="log4net.Filter.PropertyFilter">
      <key value="NDC" />
      <stringToMatch value="Serilog-Log4NetSink" />
      <acceptOnMatch value="false" />
    </filter>
    <bufferSize value="1" />
    <serverUrl value="http://localhost:5341/" />
  </appender>
  <root>
    <level value="All" />
    <appender-ref ref="TraceAppender" />
    <appender-ref ref="SeqAppender" />
  </root>
</log4net>

(More information.)

serilog-sinks-log4net's People

Contributors

luk355 avatar merbla avatar nblumhardt avatar sheastrickland avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

serilog-sinks-log4net's Issues

log4net doesnt works with UWP

I get this error when installing log4net sinks in my UWP apps.

Install-Package : Package Serilog.Sinks.Log4Net 1.5.16 is not compatible with uap10.0.14393 (UAP,Version=v10.0.14393).

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.