title: Log4Net: Using the C# AdoNetAppender with a custom Xml layout
body: <p>I'm a bit stuck. I've been writing a logging module which requires the appender being able to execute a stored procedure on the database to log our information. I have written a custom xml layout which is as follows:</p>
  
  <pre><code>protected override void FormatXml(XmlWriter writer, LoggingEvent loggingEvent)
      {
          writer.WriteStartElement("LogEntry");
  
          writer.WriteStartElement("DateTime");
          writer.WriteString(loggingEvent.TimeStamp.ToLongTimeString());
          writer.WriteEndElement();
  
          writer.WriteStartElement("Message");
          writer.WriteString(loggingEvent.RenderedMessage);
          writer.WriteEndElement();
  
          writer.WriteStartElement("User");
          writer.WriteString(loggingEvent.UserName);
          writer.WriteEndElement();
  
          writer.WriteStartElement("Process");
          writer.WriteString(loggingEvent.ThreadName);
          writer.WriteEndElement();
  
          writer.WriteStartElement("Severity");
          writer.WriteString(loggingEvent.Level.ToString());
          writer.WriteEndElement();
  
          writer.WriteStartElement("Title");
          writer.WriteString(loggingEvent.LoggerName);
          writer.WriteEndElement();
  
          writer.WriteStartElement("Class");
          writer.WriteString(loggingEvent.LocationInformation.ClassName);
          writer.WriteEndElement();
  
          writer.WriteStartElement("Filename");
          writer.WriteString(loggingEvent.LocationInformation.FileName);
          writer.WriteEndElement();
  
          writer.WriteEndElement();
      }
  </code></pre>
  
  <p>So basically, i'd like the AdoNetAppender to run the logging event through this layout and then execute the storproc with the resulting Xml as the parameter. i.e. </p>
  
  <pre><code>EXEC Logging.InsertEntry @XML
  </code></pre>
  
  <p>Unfortunately there doesn't seem to be any examples around.</p>
  
  <p>Any help would be extremely appreciated.</p>