title: How to Integrate Autofac and Log4Net with ASP.NET Web API 2 Application
body: <p>I have been moving in circles for the last few hours trying to integrate Autofac and ASP.NET Web API 2 Application. I have been following the <a href="http://autofac.org/" rel="nofollow">Autofac</a> and and its wiki at <a href="https://code.google.com/p/autofac/wiki/WebApiIntegration" rel="nofollow">Integrating with ASP.NET Web API</a>.</p>
  
  <p>But clearly, this wiki is outdated for Web API 2. Does anyone have a way i could configure my application to work with Autofac? I am just about giving up and going back to Ninject.</p>
  
  <p>I have installed <a href="http://www.nuget.org/packages/Autofac/" rel="nofollow">Autofac</a>, <a href="http://www.nuget.org/packages/Autofac.WebApi2/" rel="nofollow">Autofac.WebApi2</a> and <a href="http://www.nuget.org/packages/Autofac.Mvc5/" rel="nofollow">Autofac.Mvc5</a></p>
  
  <p><strong>I can't call the following</strong></p>
  
  <p><code>containerBuilder.RegisterApiControllers(Assembly.GetExecutingAssembly());</code></p>
  
  <p><code>.InstancePerApiRequest();</code> not reachable. In fact, anything i try to call with Api in the name is not defined. (Such as <code>RegisterApiControllers, AsWebApiActionFilterFor, RegisterWebApiFilterProvider, InstancePerApiRequest, InstancePerApiControllerType</code>)</p>
  
  <p>Also, i am trying to use Log4Net and i have implemented the Module as per wiki, now in the LoggingActionFilter shown in the wiki, what do i replace this line with as Log4Net does not contain a definition for <code>Write</code></p>
  
  <p><code>_logger.Write(actionContext.ActionDescriptor.ActionName);</code></p>