title: Send an Email When an Error Occurs in C# using log4net
body: <p>Currently my application is using log4net to log errors, the <code>web.config</code> for this is as followed:</p>
  <pre><code>&lt;log4net&gt;
      &lt;appender name=&quot;FileAppender&quot; type=&quot;log4net.Appender.RollingFileAppender&quot;&gt;
        &lt;file type=&quot;log4net.Util.PatternString&quot; value=&quot;../../logs/gateway_%date{yyyyMMdd}.log&quot; /&gt;
        &lt;appendToFile value=&quot;true&quot; /&gt;
        &lt;rollingStyle value=&quot;Date&quot; /&gt;
        &lt;datePattern value=&quot;yyyyMMdd&quot; /&gt;
        &lt;layout type=&quot;log4net.Layout.PatternLayout&quot;&gt;
          &lt;conversionPattern value=&quot;%date [%thread] %-5level %logger [%property{NDC}] – %message%newline&quot; /&gt;
        &lt;/layout&gt;
      &lt;/appender&gt;
      &lt;root&gt;
        &lt;level value=&quot;DEBUG&quot; /&gt;
        &lt;appender-ref ref=&quot;RollingLogFileAppenderOutput&quot; /&gt;
      &lt;/root&gt;
    &lt;/log4net&gt;
  </code></pre>
  <p>However, the client now wants each error to be emailled to them.</p>
  <p>What is the easiest way to do this, can you do it within the <code>web.config</code> file?</p>