title: Implementing a custom log4net PatternLayout
body: <p>I need log4net to produce a CSV file and have uncovered <a href="http://element533.blogspot.com/2010/05/writing-to-csv-using-log4net.html" rel="nofollow">this article that implements one</a>. My problem is how to integrate that code to my web project. A straight-up copy paste leaves ReSharper insisting that the namespace be changed from '<strong>CsvLogging</strong>' to '<strong>MyApp.Web</strong>' which makes sense in that now, the web project's assembly now has a class named '<strong>CsvLogging</strong>'.</p>
  
  <p>But log4net is not happy and tosses the error pasted below.</p>
  
  <p>My appender's config looks like:</p>
  
  <pre><code>&lt;layout type=" MyApp.Web.CsvLogging.CsvPatternLayout, MyApp.Web.CsvLogging"&gt;
  </code></pre>
  
  <p>...which from my reading of <a href="https://dejanfajfar.wordpress.com/2011/04/14/log4net-custom-layoutpattern/" rel="nofollow">this article on how to reference a custom pattern</a> , should be correct.</p>
  
  <pre><code>log4net:ERROR Failed to find type [ MyApp.Web.CsvLogging.CsvPatternLayout, MyApp.Web.CsvLogging]
  System.IO.FileNotFoundException: Could not load file or assembly 'MyApp.Web.CsvLogging' or one of its dependencies. The system cannot find the file specified.
  File name: 'MyApp.Web.CsvLogging'
     at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
     at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark&amp; stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
     at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark&amp; stackMark)
     at System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)
     at log4net.Util.SystemInfo.GetTypeFromString(Assembly relativeAssembly, String typeName, Boolean throwOnError, Boolean ignoreCase)
     at log4net.Util.SystemInfo.GetTypeFromString(String typeName, Boolean throwOnError, Boolean ignoreCase)
     at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.CreateObjectFromXml(XmlElement element, Type defaultTargetType, Type typeConstraint)
  </code></pre>