My.Application.Log pls help with sample

H

herbert

The sample in MacDonald's VB.2005 Developers Notebook does not work.

I get the log message in the VS.2oo8 output windows, however neither in XML
file, log file or windows event log.
I am running english VS.2008 on German Win XP SP2.

This is the app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<!-- in the sources subsection, you name the trace listeners you want to
use, choosing from the
sharedListeners list -->
<!-- Enable all three trace listeners (from the <sharedListeners>
section). -->
<sources>
<source name="Microsoft.VisualBasic.MyServices.Log.WindowsFormsSource"
switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<add name="EventLog"/>
<add name="Xml"/>
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information"/>
</switches>

<!-- Define three trace listeners that you might want to use. -->
<!-- In the sharedListeners subsection, you define the trace listeners you
want to havethe option of using,
specify any related configuration properties, and assign a escriptive name.
-->
<sharedListeners>
<add name="FileLog" type="System.Diagnostics.FileLogTraceListener,
Microsoft.VisualBasic, Version=8.0.1200.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter" />
<add name="EventLog" type="System.Diagnostics.EventLogTraceListener"
initializeData="Anwendung">
<!-- <filter type="System.Diagnostics.SeverityFilter"
initializeData="Error" /> -->
</add>
<add name="Xml" type="System.Diagnostics.XmlWriterTraceListener"
initializeData="c:\SampleLog.xml" />
</sharedListeners>
</system.diagnostics>
</configuration>

and this is the console app:
Sub Main()
Dim ts As System.Diagnostics.TraceSource
ts = My.Application.Log.TraceSource
Console.WriteLine("Tracesource: " & ts.ToString)

My.Application.Log.WriteEntry("This is a test!",
TraceEventType.Information)
Console.WriteLine("Event log entry written.")

' Write it immediately so you can view while the application is
running.
Console.WriteLine("Hit Enter to flush the log file.")
Console.ReadLine()
My.Application.Log.TraceSource.Flush()
Console.WriteLine("Now you can open the log file using Editor.")

Console.WriteLine(vbCrLf & "Hit Enter to exit.")
Console.ReadLine()
End Sub

What is wrong with the config?
thanky you very much herbert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top