Skip to content

caveman-dick/slf4net

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Simple Logging Facade for .Net (slf4net)

The slf4net project serves as a light weight abstraction layer for various logging frameworks such as log4net and NLog. This allows the end user to plug in the desired logging framework at deployment time.

This project was inspired by the Java slf4j project (which it tries to follow as closely as possible) and an earlier .Net slf project.

Installing slf4net

Find slf4net on nuget.org: http://nuget.org/packages?q=slf4net

When deploying your application, choose either the slf4net.log4net or slf4net.NLog package, or create your own wrapper for your favourite logging framework.

Configuration

See the configuration wiki page.

Getting started

Intall the slf4net nuget package to your project. If a logger factory is not configured, a NOPLogger (no operation logger) will be used. Start logging.

using System;

namespace slf4net.Samples
{
    public class MyClass
    {

        private static readonly slf4net.ILogger _logger = slf4net.LoggerFactory.GetLogger(typeof(MyClass));

        public void Foo()
        {
            _logger.Trace("Foo started at {0}.", DateTime.Now);

            // Do some work

            _logger.Trace("Foo() completed at {0}.", DateTime.Now);
        }

    }
}

License terms

slf4net is published under the MIT license.

About

Simple Logging Facade for .Net

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%