473,654 Members | 3,107 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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)?
Jan 21 '06 #1
3 1276
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]
- mv*@spam.guard. caspershouse.co m

"asapjim" <as*****@discus sions.microsoft .com> wrote in message
news:EF******** *************** ***********@mic rosoft.com...
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)?

Jan 21 '06 #2
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:
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]
- mv*@spam.guard. caspershouse.co m

"asapjim" <as*****@discus sions.microsoft .com> wrote in message
news:EF******** *************** ***********@mic rosoft.com...
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)?


Jan 22 '06 #3
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]
- mv*@spam.guard. caspershouse.co m

"asapjim" <as*****@discus sions.microsoft .com> wrote in message
news:CB******** *************** ***********@mic rosoft.com...
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:
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]
- mv*@spam.guard. caspershouse.co m

"asapjim" <as*****@discus sions.microsoft .com> wrote in message
news:EF******** *************** ***********@mic rosoft.com...
> 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)?


Jan 23 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1692
by: Trace User | last post by:
Hello, I have a design question regarding Tracing and Trace Switches. I understand that Trace Switches can be configured through an application's .config file. When a switch is instantiated, the application automatically checks the configuration file for a matching named switch. If there's a match, the configuration parameters are set.
2
1200
by: Richard | last post by:
Hello, I have a web application where I am doing alot of the work in a separate namespace that isn't part of a web page. I would like to be able to trace into this section of code, but because it's not a 'Page' object the Page.Trace isn't doable. Does anyone have any suggestions as to how I can implement tracing in this separate code? Writing to an output file isn't doable either because our customers will not allow write access to...
5
1575
by: Dabbler | last post by:
When I first start up an ASP.NET application with tracing enabled in web.config the first few pages show trace at bottom of the page but then at some point the pages return to normal with no trace information displayed. Can anyone tell me what might be causing the Trace to turn off? Thanks for any help with this ..NET 1.1 running on localhost
2
1752
by: deepukutty | last post by:
Hi all, I know tht we can do tracing in two ways.one in application level and the other is at Page level. I am able to see the details of trace either on the page itself or .../trace.axd page. I want to use maximum out of the available trace details . or let me put it like this.... tell me the actual scenario's where these trace details will be use ful and
0
1363
by: cnys | last post by:
We have an ASP.NET 2.0 (C#) app and we're trying to add tracing into it. The tracing functionality within .NET is great, but when we output this to a file, it's kind of sparse. So, we're looking for ideas on how to get more tracing info. output to our log file than what's currently output by calling the Write methods. Here are some snippets of what we're thinking of:
0
1329
by: rehto | last post by:
We have an ASP.NET 2.0 (C#) app and we want to enable tracing (see the code snippets below). The first time a user navigates to the app., the tracing works fine (the ASP.NET tracing appears on the screen and writes to a text file). The problem happens any subsequent time the app. is used--tracing doesn't happen. It's as if tracing just turns itself off. So, we only get tracing on the first time the app runs but never any other time. ...
2
1261
by: bonk | last post by:
I am using .NET 2.0 tracing to log messages within my application and app.config (<System.Diagnostics>) to configure it. I would like to be able to configure tracing in a finer grained manner than it is currently possibile out of the box. Especially I would like 1. the filnames where the traceevent end up to be dynamically generated (e.g. based on date and the tracesource). This should be configurable somewhere in the app.config by...
0
981
by: Rick | last post by:
I'm trying to implement application tracing for a single session but am not having much luck. I'd like to isolate TraceContext application level messages for a single session and have them logged to trace.axd (or even a file). The TraceContext class is sealed and exposes no useful events so it's pretty uncooperative. I have also been looking at the WebPageTraceListener class but am not sure if it is much use in this quest. Any ideas? TIA
1
1714
by: RedLars | last post by:
Hi Does the class System.Diagnostics.Trace use a singelton ? I'm able to do this; System.Diagnostics.Trace.WriteLine("test"); However, these give compiler errors; System.Diagnostics.Trace myTrace = new System.Diagnostics.Trace; // A new expression requires () or
0
8375
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8290
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8815
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8593
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7306
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2714
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1593
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.