title: How to define custom TraceListener in app.config
body: <p>I have implemented a custom trace listener (derived from <code>TextWriteTraceListener</code>) and now I would like to set my application to use it instead of standard <code>TextWriteTraceListener</code>.</p>
  
  <p>First I added default <code>TextWriteTraceListener</code> in order to make sure it works ok and it does. Here's my app.config:</p>
  
  <pre><code>&lt;configuration&gt;
      &lt;system.diagnostics&gt;
          &lt;trace autoflush="true" indentsize="4"&gt;
              &lt;listeners&gt;
                  &lt;add name="TextListener"  type="System.Diagnostics.TextWriterTraceListener" initializeData="trace.log" /&gt;
              &lt;remove name="Default" /&gt;
              &lt;/listeners&gt;
          &lt;/trace&gt;
      &lt;/system.diagnostics&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Now my trace listener is defined in <code>MyApp.Utils</code> namespace and it's called <code>FormattedTextWriterTraceListener</code>. So I changed the type in the config above to <code>MyApp.Utils.FormattedTextWriterTraceListener</code> and it currently looks like that:</p>
  
  <pre><code>&lt;configuration&gt;
      &lt;system.diagnostics&gt;
          &lt;trace autoflush="true" indentsize="4"&gt;
              &lt;listeners&gt;
                  &lt;add name="MyTextListener" type="MyApp.Utils.FormattedTextWriterTraceListener" initializeData="trace.log" /&gt;
              &lt;remove name="Default" /&gt;
              &lt;/listeners&gt;
          &lt;/trace&gt;
      &lt;/system.diagnostics&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>However now when I try to log something I'm getting a <code>ConfigurationErrorsException</code> with the message:</p>
  
  <blockquote>
    <p>Couldn't find type for class MyApp.Utils.FormattedTextWriterTraceListener.</p>
  </blockquote>
  
  <p>Does anyone knows how can I set up this custom listener in config and if it's even possible?</p>