473,385 Members | 2,069 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,385 software developers and data experts.

Usage of the TraceSource object in asp.net

Hi

We have to decided to use standard .net components for logging our asp.net
application (rather than log4.net or microsoft logging application blocks):
i tried to implement our logging using the TraceSource class. However, it
does not log anything. It works in a windows application but not in asp.net.

Am i doing something wrong or does the TraceSource class not work with
asp.net 2.0 ? This seems rather strange to me. At the bottom you find code
snippets from my web.config and my logging function:

Thanks for any help.

By the way, i do not seem to be the only one having this problem:
http://www.thescripts.com/forum/thread683962.html (Unfortunately, the guy
didnt get an answer)
<system.diagnostics>

<sources>

<source name ="Test">

<listeners>

<add name ="DelimitedListTraceListener" />

</listeners>

</source>

<source name ="Default">

<listeners>

<add name ="XmlWriterTraceListener" />

</listeners>

</source>

</sources>

<sharedListeners>

<add name="DelimitedListTraceListener"
type="System.Diagnostics.DelimitedListTraceListene r" delimiter=":"

initializeData="delimitedOutput.txt"

traceOutputOptions="ProcessId, DateTime" />

<add name="XmlWriterTraceListener"
type="System.Diagnostics.XmlWriterTraceListener"

initializeData="xmlOutput.xml"

traceOutputOptions="ProcessId, DateTime"

/>

</sharedListeners>

<switches>

<add name="Test" value="Verbose"/>

<add name="default" value="Verbose"/>

</switches>

</system.diagnostics>

Logging function:

public void Log(Exception pException, string pOriginStringOrKey,
TraceEventType pTraceEventType, bool pAddEnvironmentInformation)

{

try

{

if (pAddEnvironmentInformation)

{

IEnvironmentProvider provider =
EnvironmentProviderFactory.GetEnvironmentProvider( );

provider.AddEnvInformationToException(pException);

}

string messageString = GetMessageStringFromException(pException);

// log to specific tracesource

try

{

TraceSource traceSource = new TraceSource(pOriginStringOrKey);

traceSource.TraceEvent(pTraceEventType, 0, messageString);

traceSource.Flush();

}

catch

{

}

// log to default trace source

try

{

TraceSource defaultTraceSource = new TraceSource(DEFAULTRACESOURCE);

defaultTraceSource.TraceEvent(pTraceEventType, 0, messageString);

defaultTraceSource.Flush();

}

catch

{

}

}

catch

{

// ignore exceptions in log

}

}



I am trying to use the TraceSource object
Sep 5 '07 #1
3 3010
H

I stumpbled over a few good link.

http://msdn2.microsoft.com/en-us/library/b0ectfxd.aspx

other good links concerning this topic are:
http://forums.microsoft.com/MSDN/Sho...geid=0#1961758
(forum entry from a guy having the same question)
http://msdn2.microsoft.com/en-us/library/y13fw6we.aspx
Greetings
Sep 6 '07 #2
HI

has anyone found a good solution or having the same problem?

Greetings
Sep 25 '07 #3
Hi

It still does not work, so we resorted to use Log4Net, which works very
well.

Greetings

Sep 28 '07 #4

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

Similar topics

5
by: SDS | last post by:
I am writing an ASP.NET application (in C#) that, as part of a particular response, populates a MemoryStream object with binary data that is being collected from a Process object's StandardOutput. ...
2
by: Fish | last post by:
I have been researching the correct way to organize my solution so that it makes best use of VB.NET inherent ability to manage resources such as objects. My solution contains 2 projects and the...
0
by: George Fresin | last post by:
Hi, in my ASP.NET application I use System.Diagnostic.Trace() statements to dump onto my log. Now I must use a TraceSource object (by the way, I've noticed that TraceSource does not support...
0
by: herbert | last post by:
1) I configure a flatfile as listener in app.config to be used with TraceSource. This appends output when restarting the application. How do I specify that the existing file should be overwritten...
1
by: herbert | last post by:
I am using a TraceSource object configured via app.config. In order to delete the old file before starting the new trace, I need to obtain the filename from the listener. What am I doing wrong in...
0
by: Kam | last post by:
Hi, I am trying to create a class library project to manipulate System.Diagnostics.TraceSource class which uses a configuration file to output event and error etc.. The problem I am having is...
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: =?Utf-8?B?QWxleA==?= | last post by:
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...
1
by: mquincey | last post by:
One of the features offered by .NET 2.0 is the use of the TraceSource class. In an attempt to demonstrate its use, I wanted to run my test under the following conditions: 1. Use TraceSource class...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.