473,320 Members | 1,939 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Support of System.Diagnostics.TraceSource in ASP.NET. Please help!

Hi.

Does anybody know if System.Diagnostics.TraceSource is supported under
ASP.NET? I've used this class along with SourceSwitch and
TextWriterTraceListener in Windows apps but this is the first time I attempt
it in a web app. Specifically, does anyone know why the code below works in a
Windows application but not under an ASP.NET application?

What's interesting (frustrating I should say, since I don't understand the
behavior) is that in the web app, the last 2 lines do get executed if you
step through the code. Line oTSource.TraceData (3rd from the bottom) however,
is totally bypassed. In addition if you perform a Rename on the oTSource
object, all of the instances in the code change except again for the line 3rd
from the bottom. So somehow it is clear ASP.NET is not recognizing this line
but I have no idea why.

' set up the trace objects
Dim oTSource As New System.Diagnostics.TraceSource("TSource")
Dim oTSwitch As New System.Diagnostics.SourceSwitch("TSwitch", "Information")
Dim oTListener As New
System.Diagnostics.TextWriterTraceListener("C:\App Log.txt", "TListener")

' assign the switch to the trace source object
oTSource.Switch = oTSwitch

' add the listener to the listeners collection of trace source object
oTSource.Listeners.Add(oTListener)

' remove the default listener
oTSource.Listeners.Remove("Default")

' log a message to the C:\AppLog.txt file. File permissions have to allow
for this.
oTSource.TraceData(Diagnostics.TraceEventType.Info rmation, 1, "Tracing
message")

' flush the trace source to force writing to the file.
oTSource.Flush()

' close it
oTSource.Close()
Regards,
-Alex

Jul 26 '07 #1
0 2493

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

Similar topics

2
by: Naresh | last post by:
I have been having a problem and I don't know where to go for help. The microsoft support is only for a fees. Can anyone at all please at least point to a site or some place where I can hope for some...
5
by: toby | last post by:
Can any one help? I'm trying to use System.Diagnostics.Process.Start to open legacy MS access aplications (ade and mdb files) and vb 6 .exe's using asp.net. There is something confusing going on?!?...
2
by: Eranga | last post by:
I have a windows application in C# which has the following method public void InitiateSession(string server,string userName, string passWd ) { //To start the command...
4
by: Jiho Han | last post by:
I have the following defined in web.config under <configuration> node: <system.diagnostics> <switches> <add name="MainSwitch" value="4"/> </switches>
2
by: AMDRIT | last post by:
Hello everyone, I have created a custom component and one of its properties is a class object with it's own properties. During runtime, I can assign values to the class object properties just...
11
by: Nurit N | last post by:
This is the third newsgroup that I'm posting my problem. I'm sorry for the multiple posts but the matter becoming urgent. I hope this is the right place for it... I have created a very...
1
by: Ashkan Daie | last post by:
Hi All, When trying to install a performance counter via InstallUtil I get the following exception: Creating performance counter category Enterprise Library Caching. An exception occurred...
2
by: Rupali | last post by:
Hi all, I am tring to call a .vbs file using System.Diagnostics.Process class with following code. Process objProcess = new Process(); objProcess.StartInfo.FileName = "C:\\testScript.vbs";...
0
by: Pawel Pabich | last post by:
Hi, access a file because it's been locked by other process. I create lots of TraceSource obejcts and I suppose that some of the listeners are not closed properly. Is it any way to get all...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.