Skip to content

tagolog/logging

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tagolog

Tagolog is a free .NET library for structured logging like a breeze. Tagolog libraries are

  • Tagolog NuGet Version - general tags and tag context support.
  • Tagolog.NLog NuGet Version - adapter for .NET logging library NLog

Getting started

  • Install Tagolog and Tagolog.NLog NuGet packages.
  • Surround your code fragments with tag scopes, fill scopes with structured tags (meta information).
using ( var tagScope = TagScopeManager.CreateScope() )
{
    scope.Tags[ "UserId" ] = "jdoe";
    scope.Tags[ "VirtualMachine" ] = "appserver4.jdoe.tld";

    // ...
    log.Info( "Stopping virtual machine..." );
    // ...
}
  • Modify your application config file append "tagolog" section. app.config example
  • Modify your NLog configuration. NLog.config example
  • Use tagologmdcitem or tagologmdc layout renderers to access your tag values
<target fileName="${basedir}/${tagologmdcitem:item=Application}.log.txt"
    name="HumanReadableFile" xsi:type="File" 
    layout="${date:format=HH\:mm\:ss} ${level} ${message}${newline}${tagologmdc:tagKey=#tagKey#:tagValue=#tagValue#:orderBy=true:builtInTags=false:format=  [#tagKey#\:#tagValue#]\\n}" />
<target name="JsonFile" xsi:type="File" fileName="${basedir}/log.json.txt" >
    <layout xsi:type="TagologJsonLayout" SuppressSpaces="True" BuiltInTagsEnabled="True">
        <attribute name="TimestampLocal" layout="${longdate}" />
        ....
  • Grab json logs with your business tags to your favourite centralized log storage like Elasticsearch or Graylog

License

Tagolog is open source software, licensed under the terms of BSD license. Tagolog.NLog is open source software, licensed under the terms of BSD license. See license.txt for details.

How to build

Use Visual Studio 2013/2015. Solution files are:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors