title: Simple tracing in ASP.NET 4
body: <p>I'd like to use the System.Diagnostics.Trace class to perform simple tracing of my application in a text file. The reason I want to use this and not log4net or any other solution, it is because ... it has to be simple :)</p>
  
  <p>So, I got this working in C#:</p>
  
  <pre><code>        TextWriterTraceListener listener = new TextWriterTraceListener(Server.MapPath("~/App_Data/log.txt"));
          listener.Filter = new EventTypeFilter(SourceLevels.Warning);
          Trace.Listeners.Add(listener);
  </code></pre>
  
  <p>Or its equivalent in the Web.config:</p>
  
  <pre><code>  &lt;system.diagnostics&gt;
      &lt;sharedListeners&gt;
        &lt;add name="log" type="System.Diagnostics.TextWriterTraceListener" initializeData="App_Data/log.txt"&gt;
          &lt;filter type="System.Diagnostics.EventTypeFilter"  initializeData="Warning" /&gt;
        &lt;/add&gt;
      &lt;/sharedListeners&gt;
      &lt;trace autoflush="true"&gt;
        &lt;listeners&gt;
          &lt;clear/&gt;
          &lt;add name="log"/&gt;
        &lt;/listeners&gt;
      &lt;/trace&gt;
    &lt;/system.diagnostics&gt;
  </code></pre>
  
  <p>So when I execute this:</p>
  
  <pre><code>        Trace.TraceInformation("info");
          Trace.TraceWarning("warning");
          Trace.TraceError("error");
  </code></pre>
  
  <p>I got the lines about warning and error, that is what I was expecting. The problem is, how do I use the rest of levels that appears in the SourceLevels enum?</p>
  
  <p>Is there any drawback or using System.Diagnostics.Trace for web applications?  (autoflush is set to true for testing purposes only)</p>
  
  <p>Cheers.</p>