ASP.NET Trace from service running in web app

  • Thread starter Thread starter H Branyan
  • Start date Start date
H

H Branyan

In the Application_OnStart event in global.asax, my code calls an
AlertService which creates a System.Timers.Timer() object. So this service
doesn't actually run in conjunction with a specific aspx page, apparently.
When the timer's Elapsed event handler fires, it calls some other classes I
have written. These classes output some Trace statements that you can view
if an aspx page calls them, but I can't seem to figure out where the Trace
statements go when my service calls the classes.

Is there any way I can find the trace for this service?
 
Doing some research, I've come across the System.Diagnostics tools. I have
set up my application to write to a textfile, c:\listener.log, but while the
file was automatically created, I am not able to write to the file.

code...

web.config:

<system.diagnostics>
<switches>
<add name="tracewebforms" value="1" />
<add name="tracebusinesslogic" value="1" />
</switches>
<trace autoflush="true" >
<listeners>
<add name="ImplicitListener"
type="System.Diagnostics.TextWriterTraceListener, System,
Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
initializeData="c:\TraceListener.log"/>
<remove name="Default" />
</listeners>
</trace>
</system.diagnostics>

<compilation defaultLanguage="c#" debug="true">
<compilers>
<compiler
language="C#;Csharp"
extension=".cs"
type="Microsoft.CSharp.CSharpCodeProvider, System, Version=1.0.3300.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
compilerOptions="/d:TRACE" />
</compilers>
</compilation>

Page_load event of webform:

System.Diagnostics.Trace.WriteLineIf(Global.webformsSwitch.Enabled,"Trace
From WebForms");


What could prevent the WriteLineIf from actually writing to the file?
 
Back
Top