FIM Service Management Agent Tracing

Most people don’t realise that the Forefront Identity Manager (FIM) Management Agent (MA) utilises the Microsoft.ResourceManagement.dll as a static library for a number of operations.  What this means is that the FIM MA has the same logging interface as the FIM Service (Microsoft.ResourceManagement.Service.exe).  If you want to enable tracing for the FIM MA you do it by adding the necessary listeners and sources to the miiserver.exe.config file in a way rather similar to editing the Microsoft.ResourceManagement.Service.exe.config file.

The miiserver.exe.config file is located in the “\Microsoft Forefront Identity Manager\2010\Synchronization Service\Bin” folder of your installation. The default configuration looks like this:

<?xml version="1.0" encoding="UTF-16"?>
<configuration>
  <configSections>
    <section name="resourceManagementClient" type="Microsoft.ResourceManagement.WebServices.Client.ResourceManagementClientSection, Microsoft.ResourceManagement"/>
  </configSections>
  <startup>
    <requiredRuntime version="v2.0.50727"></requiredRuntime>
    <supportedRuntime version="v2.0.50727"></supportedRuntime>
  </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.MetadirectoryServicesEx" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="3.3.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

Let’s add tracing information.  Assuming that you have a folder C:\debug\fim\tracing\sync and both the FIM Synchronization Service and FIM MA accounts have write permission in this directory the following snippet, added after the </runtime> and before the </configuration> tags will enable verbose tracing.

  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="Verbose,ActivityTracing" propagateActivity="true">
        <listeners>
          <add type="System.Diagnostics.DefaultTraceListener" name="Default">
            <filter type="" />
          </add>
          <add name="ServiceModelTraceListener">
            <filter type="" />
          </add>
        </listeners>
      </source>

      <source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">
        <listeners>
          <add type="System.Diagnostics.DefaultTraceListener" name="Default">
            <filter type="" />
          </add>
          <add name="ServiceModelMessageLoggingListener">
            <filter type="" />
          </add>
        </listeners>
      </source>

      <source name="Microsoft.ResourceManagement" switchValue="Verbose,ActivityTracing">
        <listeners>
          <add type="System.Diagnostics.DefaultTraceListener" name="Default">
            <filter type="" />
          </add>
          <add name="ServiceModelMessageLoggingListener">
            <filter type="" />
          </add>
          <add name="ServiceModelTraceListener">
            <filter type="" />
          </add>
          <add name="text" />
        </listeners>
      </source>
    </sources>

    <sharedListeners>
      <add initializeData="C:\debug\fim\tracing\sync\miiserver_tracelog.svclog"
           type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
           name="ServiceModelTraceListener"
           traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack">
        <filter type="" />
      </add>

      <add initializeData="C:\debug\fim\tracing\sync\miiserver_messages.svclog"
           type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
           name="ServiceModelMessageLoggingListener"
           traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack">
        <filter type="" />
      </add>

      <add name="text"
           type="System.Diagnostics.TextWriterTraceListener"
           initializeData="C:\debug\fim\tracing\sync\TextWriterOutput.log"
           traceOutputOptions="DateTime, ThreadId" />
    </sharedListeners>
    <trace autoflush="true" />
  </system.diagnostics>

  <system.serviceModel>
    <diagnostics wmiProviderEnabled="true">
      <messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
    </diagnostics>
  </system.serviceModel>

If you’re ever troubleshooting a schema refresh or creation problem with the FIM MA get this enabled.  I use the following configuration file.  I just remove the comment block to enable the tracing.

<?xml version="1.0" encoding="UTF-16"?>
<!--Modified version - tracing added-->
<configuration>
  <configSections>
    <section name="resourceManagementClient" type="Microsoft.ResourceManagement.WebServices.Client.ResourceManagementClientSection, Microsoft.ResourceManagement"/>
  </configSections>

  <startup>
    <requiredRuntime version="v2.0.50727"></requiredRuntime>
    <supportedRuntime version="v2.0.50727"></supportedRuntime>
  </startup>

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.MetadirectoryServicesEx" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="3.3.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

  <!--Tracing-->
  <!--Both FIM MA and FIM Synchronization Service require WRITE access to the log file locations-->
  <!--There are three separate log file locations specified. All use explicit UPN (in this example).-->
  <!--
 <system.diagnostics>
 <sources>
 <source name="System.ServiceModel" switchValue="Verbose,ActivityTracing" propagateActivity="true">
 <listeners>
 <add type="System.Diagnostics.DefaultTraceListener" name="Default">
 <filter type="" />
 </add>
 <add name="ServiceModelTraceListener">
 <filter type="" />
 </add>
 </listeners>
 </source>

 <source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">
 <listeners>
 <add type="System.Diagnostics.DefaultTraceListener" name="Default">
 <filter type="" />
 </add>
 <add name="ServiceModelMessageLoggingListener">
 <filter type="" />
 </add>
 </listeners>
 </source>

 <source name="Microsoft.ResourceManagement" switchValue="Verbose,ActivityTracing">
 <listeners>
 <add type="System.Diagnostics.DefaultTraceListener" name="Default">
 <filter type="" />
 </add>
 <add name="ServiceModelMessageLoggingListener">
 <filter type="" />
 </add>
 <add name="ServiceModelTraceListener">
 <filter type="" />
 </add>
 <add name="text" />
 </listeners>
 </source>
 </sources>

 <sharedListeners>
 <add initializeData="C:\debug\fim\tracing\sync\miiserver_tracelog.svclog"
 type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
 name="ServiceModelTraceListener"
 traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack">
 <filter type="" />
 </add>

 <add initializeData="C:\debug\fim\tracing\sync\miiserver_messages.svclog"
 type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
 name="ServiceModelMessageLoggingListener"
 traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack">
 <filter type="" />
 </add>

 <add name="text"
 type="System.Diagnostics.TextWriterTraceListener"
 initializeData="C:\debug\fim\tracing\sync\TextWriterOutput.log"
 traceOutputOptions="DateTime, ThreadId" />
 </sharedListeners>
 <trace autoflush="true" />
 </system.diagnostics>

 <system.serviceModel>
 <diagnostics wmiProviderEnabled="true">
 <messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
 </diagnostics>
 </system.serviceModel>
 -->

</configuration>

I hope this is helpful.  I used this to troubleshoot this problem and plan on using it to blog about the other issues too.  I’ll add this to the TechNet wiki when I can work out how to use it.  I’ve been really struggling to format the XML properly and I’ve lost all the colour now!  At least the indentation is there…  Smile

About these ads

About Paul Williams

IT consultant working for Microsoft specialising in Identity Management and Directory Services.
This entry was posted in FIM, FIM 2010 and tagged , , , , , , , . Bookmark the permalink.

3 Responses to FIM Service Management Agent Tracing

  1. Pingback: (2013-11-01) Advanced Logging, Event Tracing Or Troubleshooting Within FIM Components « Jorge's Quest For Knowledge!

  2. Johnk743 says:

    Im grateful for the blog article.Much thanks again. Cool. dkgkdgdabggd

  3. Zoltan says:

    Not working for FIM 2010 R2 SP1.

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