Click here to Skip to main content
15,885,216 members
Articles / Programming Languages / C#

Slogger - The simple extensible logger

Rate me:
Please Sign up or sign in to vote.
3.17/5 (6 votes)
22 Dec 20033 min read 47.8K   899   16  
An article and library describing simple application logging and instrumentation
using System ;
using System.Collections;
using System.Diagnostics;

namespace Slogger
{
  using Utilities ;

  public sealed class SloggerListener
    : DefaultTraceListener
  {
    SinkManager _settings ;

    public SloggerListener( string filename )
    {
      SettingsReader sr = new SettingsReader( filename )  ;
      _settings = new SinkManager( sr.CloneNavigator( ) ) ;
    }

    public override void Write( string message, string category )
    {
      ArrayList al = _settings.GetSinksForEvent( category ) ;
      foreach( ISink tlb in al )
        tlb.Write( message ) ;
    }

    public override void WriteLine( string message, string category )
    {
      ArrayList al = _settings.GetSinksForEvent( category ) ;
      foreach( ISink tlb in al )
        tlb.WriteLine( message ) ;
    }
  }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
I was born at a very young age. My hobbies include reading pornography and killing squirrels.

Comments and Discussions