creamdog / Nancy.Elmah

Integrated Elmah-logging in Nancy
MIT License
8 stars 8 forks source link

Nancy.Elmah

Integrated Elmah-logging in Nancy

Installation

Install via nuget https://nuget.org/packages/Nancy.Elmah

PM> Install-Package Nancy.Elmah

Or build from source and drop Nancy.Elmah.dll and Elmah.dll into your solution

Configuration

Basic logging

namespace Nancy.Elmah.Asp.Net.Example
{
    public class Bootstrapper : DefaultNancyBootstrapper
    {
        protected override void ApplicationStartup(TinyIoc.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);
            Elmahlogging.Enable(pipelines, "elmah");
        }
    }
}

Basic logging with secured Elmah interface

namespace Nancy.Elmah.Asp.Net.Example
{
    public class Bootstrapper : DefaultNancyBootstrapper
    {
        protected override void ApplicationStartup(TinyIoc.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);
            Elmahlogging.Enable(pipelines, "elmah", new []{"administrator"});
        }
    }
}

Exception logging and select HttpStatusCode logging

namespace Nancy.Elmah.Asp.Net.Example
{
    public class Bootstrapper : DefaultNancyBootstrapper
    {
        protected override void ApplicationStartup(TinyIoc.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);
            Elmahlogging.Enable(pipelines, "elmah", new string[0], new HttpStatusCode[] { HttpStatusCode.NotFound, HttpStatusCode.InsufficientStorage, });
        }
    }
}