Skip to content

FayLibs/Fay.Logging.log4net

Repository files navigation

Fay Logging log4net

What is it?

It is a Fay Logging facade for the log4net logging framework. This facade povides 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. A more robust implementation may use a service locator or dependency inject framework to initialize the logger.

    // Initialize logger someplace
    IDelegateLogger<string> logger = new L4NSimpleLogger(((ILoggerWrapper)LogManager.GetLogger("MyLogger")).Logger);

    // 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();

Downloads

Fey Logging is available via NuGet:

Releases

No releases published

Packages

No packages published

Languages