Tracing from Class in ASP.net application

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • asapjim

    Tracing from Class in ASP.net application

    Hi, I have a C# class that is being used by an ASP.net application. How can
    I include the tracing from the class in the ASP.net application's trace
    output (trace.axd)?
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Tracing from Class in ASP.net application

    asapjim,

    You can get the current HttpContext through the static Current property
    on the HttpContext. Once you have the HttpContext instance, you can use the
    Trace property on the HttpContext to access the same TraceContext instance
    that a Page would return.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "asapjim" <asapjim@discus sions.microsoft .com> wrote in message
    news:EF43518C-8CF3-498B-9FFE-8437D426B2C5@mi crosoft.com...[color=blue]
    > Hi, I have a C# class that is being used by an ASP.net application. How
    > can
    > I include the tracing from the class in the ASP.net application's trace
    > output (trace.axd)?[/color]


    Comment

    • asapjim

      #3
      Re: Tracing from Class in ASP.net application

      Nicholas, thanks for the reply. I got your suggestion to work on a class
      instantiated by a Page. However, my class is a Singelton that is created in
      Global.asax.cs in the Application_Sta rt event. The Tracing output from the
      Singleton class doesn't go anywhere.

      "Nicholas Paldino [.NET/C# MVP]" wrote:
      [color=blue]
      > asapjim,
      >
      > You can get the current HttpContext through the static Current property
      > on the HttpContext. Once you have the HttpContext instance, you can use the
      > Trace property on the HttpContext to access the same TraceContext instance
      > that a Page would return.
      >
      > Hope this helps.
      >
      >
      > --
      > - Nicholas Paldino [.NET/C# MVP]
      > - mvp@spam.guard. caspershouse.co m
      >
      > "asapjim" <asapjim@discus sions.microsoft .com> wrote in message
      > news:EF43518C-8CF3-498B-9FFE-8437D426B2C5@mi crosoft.com...[color=green]
      > > Hi, I have a C# class that is being used by an ASP.net application. How
      > > can
      > > I include the tracing from the class in the ASP.net application's trace
      > > output (trace.axd)?[/color]
      >
      >
      >[/color]

      Comment

      • Nicholas Paldino [.NET/C# MVP]

        #4
        Re: Tracing from Class in ASP.net application

        In this case, you can not store the trace context at the class level.
        You need to retrieve it in every call that the object makes.

        --
        - Nicholas Paldino [.NET/C# MVP]
        - mvp@spam.guard. caspershouse.co m

        "asapjim" <asapjim@discus sions.microsoft .com> wrote in message
        news:CB2003F6-9097-42AE-9A28-6F7DCB274FBC@mi crosoft.com...[color=blue]
        > Nicholas, thanks for the reply. I got your suggestion to work on a class
        > instantiated by a Page. However, my class is a Singelton that is created
        > in
        > Global.asax.cs in the Application_Sta rt event. The Tracing output from
        > the
        > Singleton class doesn't go anywhere.
        >
        > "Nicholas Paldino [.NET/C# MVP]" wrote:
        >[color=green]
        >> asapjim,
        >>
        >> You can get the current HttpContext through the static Current
        >> property
        >> on the HttpContext. Once you have the HttpContext instance, you can use
        >> the
        >> Trace property on the HttpContext to access the same TraceContext
        >> instance
        >> that a Page would return.
        >>
        >> Hope this helps.
        >>
        >>
        >> --
        >> - Nicholas Paldino [.NET/C# MVP]
        >> - mvp@spam.guard. caspershouse.co m
        >>
        >> "asapjim" <asapjim@discus sions.microsoft .com> wrote in message
        >> news:EF43518C-8CF3-498B-9FFE-8437D426B2C5@mi crosoft.com...[color=darkred]
        >> > Hi, I have a C# class that is being used by an ASP.net application.
        >> > How
        >> > can
        >> > I include the tracing from the class in the ASP.net application's trace
        >> > output (trace.axd)?[/color]
        >>
        >>
        >>[/color][/color]


        Comment

        Working...