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.
I have the default app.config with it . In my code, I use Trace.TraceInformation() and Trace.TraceError.
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.
Module1.vb
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
app.config
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="1" />
</switches>
<sharedListeners>
<add name="FileLog"
type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="HealthSurvey Console"/> -->
</sharedListeners>
</system.diagnostics>