Re: Tracing to text file in production environment (debug="false")
Ben Joyce <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.web |
|---|---|
| Message-ID | <[email protected]> |
Ahh, I just figured it out... I wasn't adding my listener to the TRACE listeners collections, only the DEBUG listeners! ----- 8< ----- 'Creates the text file that the trace listener will write to. Dim myTraceLog As New System.IO.FileStream(User.LogFile, IO.FileMode.OpenOrCreate) 'Creates the new trace listener Dim myListener As New TextWriterTraceListener(myTraceLog) 'add a listener System.Diagnostics.Debug.Listeners.Add(myListener) System.Diagnostics.Trace.Listeners.Add(myListener) ----- >8 ----- Thanks, Efran - you pointed me in the right direction - all working great now :) Cheers, Ben On 1/22/07, Efran Cobisi <[email protected]> wrote: > Hi Ben, > > I need to know a bit more about your implementation... > Is your trace.axd showing the issued traces? Did you add the custom > listener to the Trace.Listeners collection? Did you flush trace streams > (using Trace.Flush or Trace.AutoFlush) as needed? > > HTH, > > Efran Cobisi > http://www.cobisi.com > > Ben Joyce wrote: > > Hi Efran. > > > > Thanks for your response. After modifying my web.config as you > > suggest and running the application with debug="false" it appars my > > Trace.Write commands are being ignored as the customer listener I have > > setup (dumps to a text file) has not been firing. > > > > Any ideas? > > > > Cheers, > > > > Ben > > > > On 1/22/07, Efran Cobisi <[email protected]> wrote: > >> Hello Ben, > >> > >> The trace approach is the best to follow, in my opinion. To enable > >> tracing in ASP.NET just use the following directive inside your > >> web.config file (system.web section): > >> > >> <trace enabled="true" /> > >> > >> If you need to capture trace data in a custom trace listener, be sure to > >> set the writeToDiagnosticsTrace attribute (1) of this element to true > >> also. > >> > >> HTH, > >> > >> Efran Cobisi > >> http://www.cobisi.com > >> > >> References: > >> 1) > >> http://msdn2.microsoft.com/en-us/library/system.web.configuration.tracesection.writetodiagnosticstrace.aspx > >> > >> > >> > >> Ben Joyce wrote: > >> > When I deploy a site into production I set the debug flag to false in > >> > the Compilation section of web.config. When I do this the debug.write > >> > statements I have in my code are ignored so nothing gets written to > >> > the text files listener I have set up. > >> > > >> > I've tried using trace.write instead so I can still get stuff > >> > outputted to a file when the site is running, but my trace.write > >> > statements also seem to be ignored. > >> > > >> > Is there some further configuration I have to do to enable this? > >> > > >> > Cheers, > >> > > >> > Ben =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com