Tracing using a global trace object...

W

Wayne

Hi,
I wonder how I should use dotNets TraceSource logging class globally within my C# application.

All examples I have seen only use the TraceSource class in the Main method but I need to use it from everywhere...

Should I wrap the TraceSource object into a Singleton class or is there a better way of doing this?

Thanks in advance!
/Wayne
 
O

Oliver Sturm

Hello Wayne,
All examples I have seen only use the TraceSource class in the Main method
but I need to use it from everywhere...

Interesting, I think I haven't really seen any examples that work this way
:)

The main feature description in MSDN has a sample that simply uses a
static variable for a TraceSource - in this case it's private, but I don't
see a reason why you wouldn't make it public or use a public property.
Here's the article in case you haven't seen it:
http://msdn2.microsoft.com/en-us/library/ms228993.aspx

Please let me know if I'm misunderstanding your question - I'm not totally
sure my reply fits your concerns.


Oliver Sturm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top