System.Diagnostics.Trace in ASP.NET- how not to IISRESET



When Tracing in ASP.NET, the IIS process (on IIs5.1) is locking on the Trace
file, and I can't read the trace file without restarting the IIS:

Even the following does NOT work (how could I fix this??):
System.Diagnostics.Trace.WriteLine(System.DateTime.Now.ToLongTimeString()+
"--" + dirException.ToString());
System.Diagnostics.Trace.Flush();
((System.Diagnostics.TraceListener)
System.Diagnostics.Trace.Listeners[0]).Close();


This is my Session_Start:
protected void Session_Start(Object sender, EventArgs e)
{

// Create a file for output named TestFile.txt.
if (!
System.IO.File.Exists(System.Configuration.ConfigurationSettings.AppSettings["TraceLog"]))
{
myFile =
System.IO.File.Create(System.Configuration.ConfigurationSettings.AppSettings["TraceLog"]);
}
else
{
myFile =
System.IO.File.Open(System.Configuration.ConfigurationSettings.AppSettings["TraceLog"],System.IO.FileMode.Append);
}

/* Create a new text writer using the output stream, and add it to
* the trace listeners. */
System.Diagnostics.TextWriterTraceListener myTextListener = new
System.Diagnostics.TextWriterTraceListener(myFile);
System.Diagnostics.Trace.Listeners.Add(myTextListener);


}


This is my Web.Config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="TraceLog" value="c:\\dev\\test.log" />
</appSettings>

<system.web>

<!-- DYNAMIC DEBUG COMPILATION
Set compilation debug="true" to enable ASPX debugging. Otherwise,
setting this value to
false will improve runtime performance of this application.
Set compilation debug="true" to insert debugging symbols (.pdb
information)
into the compiled page. Because this creates a larger file that
executes
more slowly, you should set this value to true only when debugging
and to
false at all other times. For more information, refer to the
documentation about
debugging ASP .NET files.
-->
<compilation
defaultLanguage="c#"
debug="true"
/>


<!-- CUSTOM ERROR MESSAGES
Set customError mode values to control the display of user-friendly
error messages to users instead of error details (including a
stack trace):

"On" Always display custom (friendly) messages
"Off" Always display detailed ASP.NET error information.
"RemoteOnly" Display custom (friendly) messages only to users not
running
on the local Web server. This setting is recommended for security
purposes, so
that you do not display application detail information to remote
clients.
-->
<customErrors mode="Off"
/>

<!-- AUTHENTICATION
This section sets the authentication policies of the application.
Possible modes are "Windows", "Forms",
"Passport" and "None"
-->
<authentication mode="Windows" />

<identity impersonate="false" />

<!-- APPLICATION-LEVEL TRACE LOGGING
Application-level tracing enables trace log output for every page
within an application.
Set trace enabled="true" to enable application trace logging. If
pageOutput="true", the
trace information will be displayed at the bottom of each page.
Otherwise, you can view the
application trace log by browsing the "trace.axd" page from your
web application
root.
-->
<trace
enabled="false"
requestLimit="10"
pageOutput="false"
traceMode="SortByTime"
localOnly="true"
/>

<!-- SESSION STATE SETTINGS
By default ASP .NET uses cookies to identify which requests belong
to a particular session.
If cookies are not available, a session can be tracked by adding a
session identifier to the URL.
To disable cookies, set sessionState cookieless="true".
-->
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;user id=sa;password="
cookieless="false"
timeout="20"
/>

<!-- GLOBALIZATION
This section sets the globalization settings of the application.
-->
<globalization
requestEncoding="utf-8"
responseEncoding="utf-8"
/>

</system.web>
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="myTextListener"
type="System.Diagnostics.TextWriterTraceListener,System, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089,
initializeData=c:\dev\test.log"/>
</listeners>
</trace>
</system.diagnostics>


</configuration>

.



Relevant Pages

  • Re: Application, session and performance.
    ... individual SQL statements between each COMMIT. ... It takes some practice learning how to read 10046 trace files. ... much of the useful data contained in the trace file is either ... a session, while recording wait events and bind variables: ...
    (comp.databases.oracle.server)
  • Re: Application, session and performance.
    ... individual SQL statements between each COMMIT. ... While TKPROF can analyze 10046 trace ... much of the useful data contained in the trace file is either ... a session, while recording wait events and bind variables: ...
    (comp.databases.oracle.server)
  • Re: Using parameters: Get SQL sent to database
    ... I'd often use ODBC trace to do problem determination when an application would "eat" a rich error message and produce a polite but fairly "information-free" message. ... Note that the trace file is much more compact in this case because we're only tracing with the System.Data.1 provider. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Tracefiles not generated
    ... I think it has something to do with the trace file exceeding the ... oradebug setospid 21700 ... session or using dbms_system.set_ev). ...
    (comp.databases.oracle.server)
  • [NT] ASP.NET Session Information Leakage
    ... you can set up a Trace parameter ... Session Id: Request Type: POST ... aspx.page Begin ProcessPostData Second Try 0.207433 0.205864 ... Accept image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, ...
    (Securiteam)

Loading