title: how do you control the level of a trace listener in the config file
body: <p>I'm trying to learn the built-in features of tracing. I can't figure out how to use the config to set the level (information, warn, error) that gets written to my listen.</p>
  
  <p>I have the default app.config with it . In my code, I use Trace.TraceInformation() and Trace.TraceError. </p>
  
  <p>All of the messages are written to my text file. I want to be able to change something in the app.config to make it record Info messages or just error messages.</p>
  
  <p><strong>Module1.vb</strong></p>
  
  <pre><code>Sub Main(ByVal args() As String)
      Dim index As Integer = 0
      For Each arg As String In args
          Trace.TraceInformation(String.Format("Sub Main(): arg({1}) = {0}", arg, index))
          Trace.Flush()
  
          If arg.Split("=").Count = 2 Then
              If String.Compare(arg.Split("=")(0), "mode", True) = 0 Then _Mode = arg.Split("=")(1)
          End If
  
          index += 1
      Next
  End Sub
  </code></pre>
  
  <p><strong>app.config</strong>
  
          
              
                  
                  
              
          </p>
  
  <pre><code>    &lt;sources&gt;
          &lt;!-- This section defines the logging configuration for My.Application.Log --&gt;
          &lt;source name="DefaultSource"&gt;
              &lt;listeners&gt;
                  &lt;add name="FileLog"/&gt;
                  &lt;!-- Uncomment the below section to write to the Application Event Log --&gt;
                  &lt;!--&lt;add name="EventLog"/&gt;--&gt;
              &lt;/listeners&gt;
          &lt;/source&gt;
      &lt;/sources&gt;
      &lt;switches&gt;
          &lt;add name="DefaultSwitch" value="1" /&gt;
  
      &lt;/switches&gt;
      &lt;sharedListeners&gt;
          &lt;add name="FileLog"
               type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
               initializeData="FileLogWriter"/&gt;
          &lt;!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log --&gt;
          &lt;!--&lt;add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="HealthSurvey Console"/&gt; --&gt;
      &lt;/sharedListeners&gt;
  
  &lt;/system.diagnostics&gt;
  </code></pre>