Not Logging to WMI

Topics: Logging Application Block
Jan 19, 2007 at 7:29 AM
I'm having problems logging to WMI. The Code runs fine - with no exceptions thrown, but the namespace is never created, and i cannot see any data logged.

I have a custom LogEntry class called BaseClasses.BaseEvent, which inherits from LogEntry. It also has the following attributes:


I have an entry in the AssemblyInfo.cs file as follows:

assembly: Instrumented(@"root\MyCompanyName\Monitoring")

And the app.config file is this:

<?xml version="1.0" encoding="utf-8" ?>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=null" />
<loggingConfiguration name="Logging Application Block" tracingEnabled="true"
defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
<add listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.WmiTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=null"
traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.WmiTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=null"
name="WMI TraceListener" />
<add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity: {severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine: {machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32 Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name: {threadName}&#xD;&#xA;Extended Properties: {dictionary({key} - {value}&#xD;&#xA;)}"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=null"
name="Text Formatter" />
<add switchValue="All" name="General">
<add name="WMI TraceListener" />
<allEvents switchValue="All" name="All Events">
<add name="WMI TraceListener" />
<notProcessed switchValue="All" name="Unprocessed Category" />
<errors switchValue="All" name="Logging Errors & Warnings">


And, finally, logging the event as follows:

BaseClasses.BaseEvent evnt = new WMI.BaseClasses.BaseEvent("1234", "Test", "WMI Tester");

As mentioned, no exceptions are thrown when i call this code, but the event is never written, and the namespace in not created (using the WMI Explorer in the Server Explorer in VS2005).

Can anyone point out where I could be going wrong?

Thanks in advance
Jan 19, 2007 at 10:20 AM
Ok - found the issue.
I've been testing this on my Vista box, and it won't log to WMI unless it's run as administrator.

This causes some headaches, as we see the lifetime of this framework running for about the next 3 years. With Longhorn around the corner (which I would assume uses the same permission model as Vista), we would have to run our applications in the live environment under an administrator account, which is completely against best practises.

If there are any MS reps that monitor this forum, how would you suggest we get around this?