Skip to content

mgrie/mgs.Common.Logging.NinjectModule

Repository files navigation

mgs.Common.Logging.NinjectModule

A small NinjectModule for Common.Logging.ILog

Usage

Add the NinjectModule to your Kernel

kernel.Load("*.dll");

or

kernel.Load(new Common.Logging.Ninject.NinjectModule());

Inject a Logger

Property Injection

[Inject]
public Common.Logging.ILog CommonLogger { get; set; }

MVC Base Controller

using System.Web.Mvc;
using Common.Logging;
using Ninject;

namespace YourWebApplication.Controllers
{
    public class BaseController : Controller
    {
        [Inject]
        public ILog CommonLogger { get; set; }
    }
}

Logger Name

Until you are using the Property Injection, the Logger Name equals to the Class Name of your Instance. If you use IKernel.Get<ILog>, the Logger Name belongs to Settings.Default.DefaultLoggerName

About

A small Ninject Module for Common.Logging ILog

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published