One common debugging technique is to log information in a file. Writing to a log file is most useful when real-time data is not needed or when many iterations are expected. The Forefront Identity Manager Synchronization Service (FIM Synchronization Service) includes a file, logging.xml, and one class, Logging, that control logging information.

Using the Logging Definition File

The logging.xml file contains entries that you can use to specify how logging works:

  • use-single-log element specifies whether to use one log file, or a separate log file for each management agent. The default value is false, which means each management agent gets its own log file, galsync.log, in the MaData\MA_NAME directory, where MA_NAME is the name of the management agent. If this value is true, every management agent shares a log file, galsync.log, in the MaData directory.

  • file-name specifies the name of the logging file, overriding the default name, galsync.log.

  • logging-level specifies the level at which logging messages are posted to the log file. Only messages tagged with logging levels equal to or higher than this value are logged to the log file.

Using the Logging Class

The Logging class contains a number of static methods that you can use to log messages:

  • Log logs a message with an optional timestamp at a given logging level.

  • LogException logs an exception with information about the calling method, entry in the connector space, and whether the exception was caught and handled.

  • LogException logs an exception with information about the calling method, when the exception occurred, and whether the exception was caught and handled.

  • SetupLogFile overrides the file-name and logging-level entries in logging.xml.

Creating a Reference to the Logging Assembly

Before you can use the Logging class, you must create a reference to the assembly that contains the code. The assembly is Logging.dll, which is located in the Extensions directory. If you want to avoid the fully qualified class name, you should put an import statement in your source file. For Microsoft Visual Basic, use imports Microsoft.MetadirectoryServices.Logging. For Microsoft Visual C#, use using Microsoft.MetadirectoryServices.Logging.

See Also