title: Using SQL Server Ce 4.0 with log4net
body: <p>I'm trying to use SQL Server Compact Edition (v4.0) with log4net. There's a great guide <a href="http://www.npcompetesolutions.com/Blogs/?p=3" rel="nofollow">here</a>. It uses Compact Edition 3.5, but most of the steps should be the same.</p>
  
  <p>So, I've created a SQL Server CE 4.0 database inside "App_Data" with a "Log" table in my MVC web app, and made sure that <strong>System.Data.SqlServerCe</strong> "copy local" is <strong>true</strong>. I also changed the connection string to account for the app_data folder.</p>
  
  <p>My appender looks like this:</p>
  
  <pre><code>&lt;appender name="SqlCeAppender" type="log4net.Appender.AdoNetAppender"&gt;
      &lt;connectionType value="System.Data.SqlServerCe.SqlCeConnection, System.Data.SqlServerCe" /&gt;
      &lt;connectionString value="Data Source=|DataDirectory|\='log4net.sdf'" /&gt;
      &lt;commandText
      value="INSERT INTO Log 
        ([Date],[Thread],[Level],[Logger],[Message],
        [Exception], [UserName], [Custom]) 
        VALUES 
        (@log_date, @thread, @log_level, @logger, @message, 
        @exception, @username, @custom)" /&gt;
      &lt;parameter&gt;
        &lt;parameterName value="@log_date" /&gt;
        &lt;dbType value="DateTime" /&gt;
        &lt;layout type="log4net.Layout.RawUtcTimeStampLayout" /&gt;
      &lt;/parameter&gt;
      &lt;parameter&gt;
        &lt;parameterName value="@thread" /&gt;
        &lt;dbType value="String" /&gt;
        &lt;size value="255" /&gt;
        &lt;layout type="log4net.Layout.PatternLayout"&gt;
          &lt;conversionPattern value="%thread" /&gt;
        &lt;/layout&gt;
      &lt;/parameter&gt;
      &lt;parameter&gt;
        &lt;parameterName value="@log_level" /&gt;
        &lt;dbType value="String" /&gt;
        &lt;size value="50" /&gt;
        &lt;layout type="log4net.Layout.PatternLayout"&gt;
          &lt;conversionPattern value="%level" /&gt;
        &lt;/layout&gt;
      &lt;/parameter&gt;
      &lt;parameter&gt;
        &lt;parameterName value="@logger" /&gt;
        &lt;dbType value="String" /&gt;
        &lt;size value="255" /&gt;
        &lt;layout type="log4net.Layout.PatternLayout"&gt;
          &lt;conversionPattern value="%logger" /&gt;
        &lt;/layout&gt;
      &lt;/parameter&gt;
      &lt;parameter&gt;
        &lt;parameterName value="@message" /&gt;
        &lt;dbType value="String" /&gt;
        &lt;size value="4000" /&gt;
        &lt;layout type="log4net.Layout.PatternLayout"&gt;
          &lt;conversionPattern value="%message" /&gt;
        &lt;/layout&gt;
      &lt;/parameter&gt;
      &lt;parameter&gt;
        &lt;parameterName value="@exception" /&gt;
        &lt;dbType value="String" /&gt;
        &lt;size value="2000" /&gt;
        &lt;layout type="log4net.Layout.ExceptionLayout" /&gt;
      &lt;/parameter&gt;
      &lt;parameter&gt;
        &lt;parameterName value="@username" /&gt;
        &lt;dbType value="String" /&gt;
        &lt;size value="255" /&gt;
        &lt;layout type="log4net.Layout.PatternLayout"&gt;
          &lt;conversionPattern value="%username" /&gt;
        &lt;/layout&gt;
      &lt;/parameter&gt;
      &lt;parameter&gt;
        &lt;parameterName value="@custom" /&gt;
        &lt;dbType value="String" /&gt;
        &lt;size value="255" /&gt;
        &lt;layout type="log4net.Layout.PatternLayout"&gt;
          &lt;conversionPattern value="%property{Custom}" /&gt;
        &lt;/layout&gt;
      &lt;/parameter&gt;
    &lt;/appender&gt;
  </code></pre>
  
  <p>And... nothing happens - no logs. When I swap out to my text file appender I get the logs so it's something to do with this appender - but I don't know what. Can anyone help?</p>