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 (23) -

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

Add comment

biuquote
  • Comment
  • Preview
Loading

Rel=Me

Month List

RecentComments

Comment RSS