Patrick's SharePoint Blog

SharePoint's Booming world

Using PowerShell to register SPGuidance diagnostic areas

Posted by Patrick Boom on September 16, 2010

The SPGuidance package delivers a set of components to ease certain administration tasks with SP 2010, for example logging.

It hooks in to the built-in SharePoint logging functionality and exposes a set of classes to easily log your own events in the event log, ULS logs or any custom log sources, like a database.

If one would look into this model, you will find that a diagnostic area corresponds to an event source in the event logs. For instance, if I register a diagnostic area called Boom.MyCustomApplication, the event source mentioned in the logs would read the same. This allows support engineers to easily track the source of the event and act accordingly.

However, although the diagnostic area corresponds to the event source, they are not the same. You can register diagnostic areas using the logging component of the SPGuidance set, but this does not mean a corresponding event source is also created. In fact, event sources need to be registered on each front-end separately with sufficient permissions, before the logging component can write to the event log using the diagnostic area as the event source. So how would you create the event sources on each front-end? Well, there are a couple of possible approaches:

  1. Use PowerShell to create the sources on each front-end remotely
  2. Use a Timer Job to run custom code on each front-end that registers the event source.

In this post, I will show how to do that from PowerShell. These are only two lines of code and the script can be run from a remote location on each front-end.

# First load object models to use
[void][System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.Practices.SharePoint.Common”)

# call the registration method to ensure all registered diagnostic areas are also registered as event sources
[Microsoft.Practices.SharePoint.Common.Logging.DiagnosticsAreaEventSource]::EnsureConfiguredAreasRegistered()

In this script, we first load the assembly Microsoft.Practices.SharePoint.Common.dll. We assume here that the assembly is available from the GAC. In my next post, the solution provided will ensure these assemblies are deployed to the GAC for use. Once we have done that, we can call the static EnsureConfiguredAreasRegistered method of the DiagnosticsAreaEventSource class that will iterate through all the configured and registered diagnostic areas and ensures that an event source is registered for that. The event sources will be registered on the Application event log. During the next couple of days, I will also investigate the possibility of registering the sources to different logs.

In the next post, I will show a custom solution on how to create additional diagnostic areas and use a timer job to ensure the event sources are created at the front end. Till next time!

Advertisements

9 Responses to “Using PowerShell to register SPGuidance diagnostic areas”

  1. […] https://patrickboom.wordpress.com/2010/09/16/using-powershell-to-register-spguidance-diagnostic-areas… […]

  2. I don’t think aging is fn fo anyone and watching those changes, bt that’s why it’s impotant to have baance in yo ife and othe things that yo’e focsed on. Fide et bien 茅ais茅, e je impessionne d猫s es pemi猫es mintes. Vous pouvez 茅galement enrichir le site en proposant 脿 votre tour des ouvrages ou des manifestations.

    ) dans ‘sine Vaeo Vision diig茅e depis 2008 pa St茅phane Pince, n ancien de Faecia et Visteon. However according to the Department, they tell Nick Bilton of the NY Times that they have yet to receive any reports of complaints or protests regarding the proceedings. Que ce soit dans ‘Faune(s)’, dans ‘Pour tout l’or du monde’ ou dans sa derni猫re cr茅ation, ‘L’Homme de l’Atlantique’, le danseur et chor茅graphe Olivier Dubois se montre nu, ou presque.

    LOUIS SHERRY, 6, Rond-Point des, Champs-Elys茅es. demande de ecettesQ’est ce q’on mangeVoici a ecette d coqe-monsie ax pommes et a bodin banc: po 4 pesonnes:8tanches de pain de mie,2pats de bodin banc,80g de gy猫e,40g de bee o magaine,4ci猫es 脿 sope de mameade de pommes non sc茅e. La compagne de Kevin Stat a 茅t茅 a ps apide en baage mais son 茅taon, Myod Cathago, a fait tombe a deni猫e bae.

    Sac 脿 main povides ike Aeghanymoon vaiety Stoe soi pe qaity, mio 鈥嬧€媔mage de Chane epica sacs 脿 main. Passionn茅 de mode et ps p茅cis茅ment de baskets montantes, e appe am茅icain de 34 ans vient de dessine ne seconde paie de chasses de spot en coaboation avec nike jordan. Elle apprend en effet de nouvnike freex 茅l茅ments sur le pass茅 de ses parents.
    [URL=http://www.free-lancer.fr/Nike_Free_enfant/free_run_nike.html – free run nike
    [URL=http://www.free-lancer.fr/Nike_Free_femme/nike_free_run_femme.html – nike free run femme
    Snaphigh nous pr茅sente sa sneaker custom, la Air Jordan XI Dirty Snakes.
    Nike Hong Kong a lanc茅 un concours pour qu’un nombre limit茅 de personnes puissent acheter la paire.

  3. I know this site presents quality dependent conntent andd extra information, is therre anyy other website which provides these stuff in quality?

  4. Britt said

    It’s remarrkable to pay a quick visit this web site and reading the views
    of all friends regarding this paragraph, while I am also keen of getting know-how.

  5. of course like your web site however you hav tto test the spelling on qite a few of youjr posts.
    Many of them are rife with spelling problems and I find it very troublesome to inform the trtuth then
    againn I wipl certainly come back again.

  6. When I initially commented I clicked tthe “Notify me when new comments are added” checkbox
    and now ewch time a comment is addded I gett four emails
    with the same comment. Is there aany waay you can remove me
    frolm that service? Thank you!

  7. insurance said

    I was curious if you ever considered changing the structure of your blog?
    Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better.
    Youve got an awful lot of text for only having one or 2 images.
    Maybe you could space it out better?

  8. smaster said

    Buy Essay Papers Online! Unique essay writing services!

  9. topycooth said

    What did you dream about tonight? I dreamed of for example Justin Bieber and I took by the hand, and then we walked , ( : I’m chustvovala as the present
    Usually I do not remember their dreams .
    http://funcats.by/uploads/pictures/funcats2/thumbs/th_20081121_011_funcats2.jpg

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: