Git Product home page Git Product logo

nlog.xml's Introduction

#NLog.Xml

NLog XML layout and fluent logging.

Build status

Version

##Download

The NLog.Xml library is available on nuget.org via package name NLog.Xml.

To install NLog.Xml, run the following command in the Package Manager Console

PM> Install-Package NLog.Xml

More information about NuGet package avaliable at https://nuget.org/packages/NLog.Xml

##Development Builds

Development builds are available on the myget.org feed. A development build is promoted to the main NuGet feed when it's determined to be stable.

In your Package Manager settings add the following package source for development builds: http://www.myget.org/F/loresoft/

##Xml Layout

Use the XML layout renderer

<target ... layout="${xml}" />

Add custom properties to the xml document

<target ...>
  <layout xsi:type="XmlLayout">
    <property name="MachineName" layout="${machinename}"/>
    <property name="ThreadID" layout="${threadid}" />
    <property name="ThreadName" layout="${threadname}" />
    <property name="ProcessID" layout="${processid}" />
    <property name="ProcessName" layout="${processname:fullName=true}" />
    <property name="UserName" layout="${windows-identity}" />
  </layout>
</target>

Write XML to file using header and footer to set xml root node.

<target xsi:type="File"
        name="fileXmlName"
        header="&lt;nlog&gt;"
        footer="&lt;/nlog&gt;"
        fileName="${logDirectory}/log.xml"
        archiveFileName="${logDirectory}/archives/log.{#}.xml"
        archiveEvery="Day"
        archiveNumbering="Rolling"
        maxArchiveFiles="7"
        concurrentWrites="true"
        createDirs="true"
        autoFlush="true">
  <layout xsi:type="XmlLayout">
    <property name="MachineName" layout="${machinename}"/>
    <property name="ThreadID" layout="${threadid}" />
    <property name="ThreadName" layout="${threadname}" />
    <property name="ProcessID" layout="${processid}" />
    <property name="ProcessName" layout="${processname:fullName=true}" />
    <property name="UserName" layout="${windows-identity}" />
  </layout>
</target>

Send MSMQ message as XML

<target xsi:type="MSMQ"
        name="messageQueue"
        recoverable="true"
        createQueueIfNotExists="true"
        label="${logger}"
        queue=".\private$\logging" >
  <layout xsi:type="XmlLayout">
    <property name="MachineName" layout="${machinename}"/>
    <property name="ThreadID" layout="${threadid}" />
    <property name="ThreadName" layout="${threadname}" />
    <property name="ProcessID" layout="${processid}" />
    <property name="ProcessName" layout="${processname:fullName=true}" />
    <property name="UserName" layout="${windows-identity}" />
  </layout>
</target>

nlog.xml's People

Contributors

304notmodified avatar pwelter34 avatar

Watchers

 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.