0
Answer

Tracing and Listners Question

Jeff

Jeff

14y
2.3k
1


I am trying to learn about tracing and listeners etc but am having a bit of trouble getting it to work.
I have this in my web config file:

<configuration>
--Other web config stuff here--
  <system.diagnostics>
    <trace autoflush="true"/>
    <sources>
      <source name="mySource"
              switchName="mySwitch"
              switchType="System.Diagnostics.SourceSwitch" >
        <listeners>
          <clear/>
          <add name="delimitedListener"
            type="System.Diagnostics.DelimitedListTraceListener"
            delimiter="|"
            initializeData="textlog.txt"
            traceOutputOptions="ProcessId, DateTime" />
        </listeners>
      </source>
    </sources>
    <switches>
      <add name="mySwitch" value="Verbose" />
    </switches>
  </system.diagnostics>
 
And this is the code behind and aspx page.
        protected void Page_Load(object sender, EventArgs e)
        {
            TraceSource source = new TraceSource("mySource");
            source.TraceEvent(TraceEventType.Verbose, 0, "Information Message");
        }
However, when I run the page, I don't get a log file generated.
Can someone please explain why and how?
Thanks
Jeff