Skip to content
A Fay Logging facade for Microsoft Enterprise Library Logging
C#
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
packages
src
.gitattributes
.gitignore
Fay Logging EntLib5.sln
Fay Logging EntLib5.v2.ncrunchsolution
Fay.Logging.EntLib5.nuspec
LICENCE.txt
README.md

README.md

Fay Logging EntLib5

What is it?

It is a Fay Logging facade for the Microsoft Enterprise Library Logging Application Block version 5. This facade provides a simple delegate logging API making logging easier, while helping to make sure any of the code required to generate a log message is not executed unless the logging level is within scope.

Quick Start

Below is a simplified example for logging strings when you don't use categories. A more robust implementation may use a service locator or dependency inject framework to initialize the logger.

    // Initialize logger someplace
    IDelegateLogger<string> logger = new EntLibSimpleMessageLogger(Logger.Writer);
    
    // Use logger as needed
    logger.Critical(() => string.Format("Some text blah {0} blah", "blah"));
    
    logger.Verbose(() =>
    {
        StringBuilder builder = new StringBuilder();
        builder.Append("Foo");
        builder.Append(" ");
        builder.Append("Bar");
        return builder.ToString();
    });
    
    // When application is done needing the logger its recommend to dispose it
    logger.Dispose();

Below is a simple example for logging to categories.

    // Initialize logger someplace
    IDelegateLogger<MessageWithCategories> logger = new EntLibSimpleCategoryLogger(Logger.Writer);
    
    // Use logger as needed
    logger.Critical(() => new MessageWithCategories(string.Format("Some text blah {0} blah", "blah"), "General", "Foo"));
    
    logger.Verbose(() =>
    {
        StringBuilder builder = new StringBuilder();
        builder.Append("Foo");
        builder.Append(" ");
        builder.Append("Bar");
        return new MessageWithCategories(builder.ToString(), "General", "Foo");
    });
    
    // When application is done needing the logger its recommend to dispose it
    logger.Dispose();

Downloads

Fey Logging EntLib 5 is available via NuGet:

You can’t perform that action at this time.