title: Using the Ninject NLogModule Logger in global.asax
body: <p>I'm using Ninject for DI in my asp.net application, so my Global class inherits from NinjectHttpApplication.</p>
  
  <p>In my CreateKernel(), I'm creating my custom modules and DI is working fine for me.</p>
  
  <p>However, I notice that there is a Logger property in the NinjectHttpApplication class, so I'm trying to use this in Application_Error whenever an exception is not caught.</p>
  
  <p>I think I'm creating the nlog module correctly for Ninject, but my logger is always null. Here's my CreateKernel:</p>
  
  <pre><code>protected override Ninject.Core.IKernel CreateKernel()
  {
      IKernel kernel = new StandardKernel(new NLogModule(), new NinjectRepositoryModule());
      return kernel;
  }
  </code></pre>
  
  <p>But in the following method, Logger is always null.</p>
  
  <pre><code>protected void Application_Error(object sender, EventArgs e) 
  {
      Exception lastException = Server.GetLastError().GetBaseException();
      Logger.Error(lastException, "An exception was caught in Global.asax");
  }
  </code></pre>
  
  <p>To clarify, Logger is a property on NinjectHttpApplication of type ILogger and has the [Inject] attribute</p>
  
  <p>Any idea how to inject correctly into Logger?</p>