Configuring a TraceSource

by Matt 27. July 2007 04:50

A common pattern in log4net is to create an instance of a logger in a class, passing in the name of the class. This logger can then be setup via config files and violin, you've got tracing that you can turn on and off at the class level. Rather handy.

TraceSource allows exactly the same thing. Simply pass a name into the constructor and define the parameters in the app.config. But the common idiom is to not build a TraceSource per class, but group them at a more logical (as in "not-physical", rather than Vulcan) level, usually named after a namespace, but sometimes also a class or other logical identifier. This gives you finer control of the logging of an entire feature set.

Why am I telling you this?

Because generally, the .net framework doesn't have much logging of what it's doing. .net 3 has tons, and it's all done through TraceSources. This page on msdn details how to turn on tracing for WCF. Here are the TraceSources defined:

  • System.ServiceModel: Logs all stages of WCF processing, whenever configuration is read, a message is processed in transport, security processing, a message is dispatched in user code, etc.
  • System.ServiceModel.MessageLogging: Logs all messages that flow through the system.
  • System.IdentityModel
  • System.ServiceModel.Activation
  • System.IO.Log: Logging for the .NET Framework interface to the Common Log File System (CLFS).
  • System.Runtime.Serialization: Logs when objects are read or written.
  • CardSpace

Quite a few sources. But looking at the recommended tracing levels, or using the Service Configuration Editor, you might be surprised to see more than just "System.ServiceModel" or "System.ServiceModel.MessageLogging". I'm certainly regretting not finding the "CardSpace" source sooner.

WPF gets in on the act too, with it's own set of TraceSources:

  • System.Windows.Media.Animation
  • System.Windows.Data: Databinding
  • System.Windows.DependencyProperty: Tracing for the dependency property system
  • System.Windows.Documents
  • System.Windows.Freezable: Tracing for objects that have been made immutable
  • System.Windows.Markup: All about XAML
  • System.Windows.NameScope: Tracing naming and the scopes used for name lookup and collisions
  • System.Windows.ResourceDictionary
  • System.Windows.RoutedEvent

The odd thing about WPF logging is that not only do you have to configure it in your app.config, you also need to enable a registry key. I don't know why the config isn't enough, I guess it's to do with performance.

Tags:

Comments (39) -

Sanora Klosterman
Sanora Klosterman
2/11/2011 5:17:45 AM #

got here form ask ... great article and I definitely can understand. Not sure if you heard, the new apple ipad might be coming out some time soon .. I am looking forward to it, pretty interesting news.

Reply

Fort Lauderdale Rentals
Fort Lauderdale Rentals
3/24/2011 6:28:21 PM #

Well I got to be honest here,Generally I do not post on blogs, but I would like to say that this publish really forced me to do so! really nice publish! Will definitly keep me coming back.!..Thanks)

Reply

network security new york
network security new york
5/19/2011 1:55:02 AM #

This is a very nice post.This is also very beautiful.
Because it contains lots of important information.It helps me a lot.I really have enjoyed reading your blog.
I will love to visit everyday.Keep up doing good work.Thank you.

Reply

LAURENCE  Debora
LAURENCE Debora
5/22/2011 4:55:59 AM #

Recherche thématique sur plusieurs thèmes, c'est sukoga.com, moteur.

Reply

LAURENCE  Debora
LAURENCE Debora
5/27/2011 8:31:56 AM #

Liste d'annuaires détaillées pour faciliter le référencement, Créez votre propre article.

Reply

suv reviews
suv reviews
7/20/2011 10:34:05 PM #

Is it ok if I quote your article in my monthly newsletter? I would think this article suits my topic perfectly. Well ya, thanks for posting this article.

Reply

best hybrid cars 2011
best hybrid cars 2011
7/22/2011 4:46:23 AM #

Per il tuo bambino scegli Moncler. Una scelta di capi, estivi ed invernali, eccezionali. Tuo figlio sarà sempre alla moda e potrà muoversi in totale comodità.

Reply

LAURENCE  Debora
LAURENCE Debora
7/27/2011 10:11:52 AM #

Bienvenue sur annuaires-gratuit.com.Des fonctionnalités inédites, nombreuses annuaires.

Reply

LAURENCE  Debora
LAURENCE Debora
7/28/2011 5:38:01 AM #

Notre objectif et de vous simplifiée les choses et faire connaître vos annuaires.

Reply

DEBORA Laurence
DEBORA Laurence
8/1/2011 7:52:31 AM #

Il ne vous reste plus qu' à créer votre propre annuaire, l'inscription est  gratuite .

Reply

DEBORA Laurence
DEBORA Laurence
8/2/2011 4:10:03 AM #

Service page annuaires : Trouver l'annuaire qu'il vous faut sur annuaires-gratuit.com .

Reply

DEBORA Laurence
DEBORA Laurence
8/8/2011 10:05:38 AM #

Vous pouvez configuré vos systèmes de paiement allopas sur annuaires-gratuit.com

Reply

john
john
8/27/2011 3:51:53 AM #

Hey , some great)inforeading more (info.. Just added to your RSS feed Smile

Reply

Miami Tree Removal Cost
Miami Tree Removal Cost
10/7/2011 6:31:03 AM #

I wish I had the time to run one of these web blogs.  This must be a lot of fun to make and run.  

Reply

Thanks for the info! I am recording this now at http://peter@sousaart.com

Reply

Eric
Eric
10/22/2011 9:45:22 AM #

Hello

Nice, post here may come back soon

Reply

Robert
Robert
10/23/2011 11:58:56 AM #

Hi

interresting, post here may come back soon
Keep like this

Reply

Stephane
Stephane
10/23/2011 7:25:30 PM #

hi,

Nice, post here
Keep like this

Reply

Stephane
Stephane
10/23/2011 8:45:34 PM #

Hello

Nice, post here
continue updating your blog

Reply

Stephane
Stephane
10/23/2011 10:50:15 PM #

Hi

Nice, post here
Keep like this

Reply

Lisa
Lisa
10/24/2011 12:23:50 AM #

Hello

interresting, post here
keep update

Reply

Lisa
Lisa
10/24/2011 12:25:30 AM #

hello there,

interresting, post here will came back
keep update

Reply

iPhone games reviews
iPhone games reviews
12/1/2011 5:02:31 AM #

Good job  , amazing Post !!!

Reply

photographe mariage paris
photographe mariage paris United States
6/8/2015 2:31:23 AM #

Thanks for this wonderful article. One other thing is that most digital cameras arrive equipped with a new zoom lens so that more or less of a scene to become included through 'zooming' in and out. All these changes in concentration length are generally reflected from the viewfinder and on big display screen right at the back of the exact camera.

Reply

Philix
Philix United States
11/19/2015 4:40:40 PM #

Ace Website.

Reply

Marianne Babers
Marianne Babers United States
1/15/2016 3:48:04 AM #

getting the last pair of shoes in your size AWESOME!

Reply

Blake Krist
Blake Krist United States
1/15/2016 4:04:10 AM #

Congrats! So glad to see this site getting the recognition it deserves, the world can always use a little more awesome.

Reply

Loren Benward
Loren Benward United States
1/15/2016 4:15:23 AM #

Printing out an essay or paper, reading the first line and realizing there aren't any mistakes.<br />AWESOME!

Reply

Jose Bacone
Jose Bacone United States
1/15/2016 4:51:30 AM #

Thaaaat IS awesome! lol hehe

Reply

Blake Krist
Blake Krist United States
1/15/2016 5:44:17 AM #

I can't wait to read this masterpiece. Ordering off the menu at fast food restaurants and old dangerous playground equipment have to be in the book!

Reply

Luvenia Colier
Luvenia Colier United States
1/15/2016 5:54:05 AM #

Let me be the first to say: Congrats, Neil! I've been following this site from day one, and have loved every single day of awesomeness that it has delivered. You deserve all the success coming your way. Keep it up!AWESOME!

Reply

Isreal Payor
Isreal Payor United States
1/15/2016 6:24:03 AM #

this is awesome like the book of awesome

Reply

Normand Schwarz
Normand Schwarz United States
1/15/2016 6:43:22 AM #

Thaaaat IS awesome! lol hehe

Reply

Lashawn Ulwelling
Lashawn Ulwelling United States
1/15/2016 7:06:43 AM #

Congrats. And all of the items featured so far should be in the book.

Reply

Dion Newcomer
Dion Newcomer United States
1/15/2016 7:14:26 AM #

Congrats! So glad to see this site getting the recognition it deserves, the world can always use a little more awesome.

Reply

Jose Bacone
Jose Bacone United States
1/15/2016 7:15:25 AM #

this is awesome like the book of awesome

Reply

Antony Goren
Antony Goren United States
1/15/2016 7:44:48 AM #

I love the dolphin saving you one.

Reply

Lashawn Ulwelling
Lashawn Ulwelling United States
1/15/2016 7:49:12 AM #

Thaaaat IS awesome! lol hehe

Reply

Freddy Stuart
Freddy Stuart United States
1/15/2016 8:29:36 AM #

Congrats! So glad to see this site getting the recognition it deserves, the world can always use a little more awesome.

Reply

Add comment

biuquote
  • Comment
  • Preview
Loading

Rel=Me

Month List

RecentComments

Comment RSS