Re: Trace.Write in helper class not showing up in Trace.axd
- From: "TJ" <teejay@xxxxxxxxxxxxxxxxx>
- Date: Wed, 25 Jan 2006 09:15:35 -0600
Your assumptions were correct and your example was thorough. Worked first
time! I've actually added another constructor to my helper class that
accepts the page reference and created a private method in the class, too,
called MyTrace(string category,string msg,string writeOrWarn)...I think you
can see where I'm going with this. Now anywhere in the class, I can just
use MyTrace() and it writes out to the Trace.axd all nice and pretty. ; )
Thanks so very much!
""Jeffrey Tan[MSFT]"" <v-jetan@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:TS6obGXIGHA.3696@xxxxxxxxxxxxxxxxxxxxxxxx
> Hi TJ,
>
> Thanks for your post.
>
> I assume you are using VS.net2003.
>
> I was able to reproduce this problem since the Trace you used in Asp.net
> webpage is different from the Trace you used in class library.
>
> In Asp.net page, Page.Trace property is of type TraceContext, while in
> Class Library, you use System.Diagnostics.Trace class.
> System.Diagnostics.Trace has no awareness of Asp.net page trace, so it
> will
> not output trace information to the webpage or Trace.axd.
>
> If you want to show the output in the trace, you have to pass the page
> reference to the class library, then the class library method can use
> Page.Trace to output the trace information. Sample code like this:
> private void Page_Load(object sender, System.EventArgs e)
> {
> this.Trace.Write("abc");
> Class1.OutputTrace(this);
> }
>
> public class Class1
> {
> public static void OutputTrace(System.Web.UI.Page page)
> {
> page.Trace.Write("def");
> }
> }
>
> In VS2005, .Net2.0 proivded an option to redirect the
> System.Diagnostics.Trace output to Page.Trace. To do this, you can
> register
> WebPageTraceListener for the Trace listener in web.config file
> <system.diagnostics>-><trace>-> <listeners> element.
>
> Hope this helps!
>
> Best regards,
> Jeffrey Tan
> Microsoft Online Partner Support
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
>
.
- Follow-Ups:
- Re: Trace.Write in helper class not showing up in Trace.axd
- From: "Jeffrey Tan[MSFT]"
- Re: Trace.Write in helper class not showing up in Trace.axd
- References:
- Trace.Write in helper class not showing up in Trace.axd
- From: TJ
- RE: Trace.Write in helper class not showing up in Trace.axd
- From: "Jeffrey Tan[MSFT]"
- Trace.Write in helper class not showing up in Trace.axd
- Prev by Date: Unable to start debugging on the web server. Logon failure
- Next by Date: Re: Unable to debug the WebApplication
- Previous by thread: RE: Trace.Write in helper class not showing up in Trace.axd
- Next by thread: Re: Trace.Write in helper class not showing up in Trace.axd
- Index(es):
Relevant Pages
|
Loading