Background: Master Data Services consists of an ASP.NET web application (Master Data Manager) and a WCF service, both hosted in IIS, plus a SQL Server 2008 R2 or 2012 database. Both Master Data Manager requests and external calls to the web services API end-point are handled by a common service layer. The service layer can log each operation request/response as well as important events and errors.
The web.config file: As an administrator with access to files on the IIS web server, you can enable logging by modifying the MDS Web.config file.
By default the Web.config file is located in one of the following web application folders:
- SQL Server 2008 R2: program_files\Microsoft SQL Server\Master Data Services\WebApplication
- SQL Server 2012: program_files\Microsoft SQL Server\110\Master Data Services\WebApplication
Caution: Updating Web.config will cause the MDS application domain in IIS to recycle. Existing user sessions will lose cached information and users may experience session errors or slow page loads. Perform changes at off-peak times if possible.The file snippet below shows the diagnostics section from the originally installed file. Note that
switchValue is set to “Off”. Additionally, the example lines that follow are commented out. These lines are examples for adding trace listeners of various types.
<system.diagnostics>
<sources>
<!-- Adjust the switch value to control the types of messages that should be logged. -->
<source name="MDS" switchType="System.Diagnostics.SourceSwitch" switchValue="Off">
<listeners>
<!-- Enable and configure listeners as desired to obtain trace messages. -->
<!-- <add name="LogFileListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="MdsTrace.log" traceOutputOptions="DateTime" /> -->
<!-- <add name="EtwListener" type="System.Diagnostics.Eventing.EventProviderTraceListener, System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"
initializeData="{F2A341B8-CA5F-49ad-B00C-A82D3FCF948B}"/> -->
<!-- <remove name="Default"/> -->
</listeners>
</source>
</sources>
<trace autoflush="true" />
</system.diagnostics>
Turning on log file tracing: To enable logging, change
switchValue to
All or another valid value as described below in Table 2. To enable the output to a log file, uncomment the LogFileListener line as shown in the file snippet below.
<system.diagnostics>
<sources>
<!-- Adjust the switch value to control the types of messages that should be logged. -->
<source name="MDS" switchType="System.Diagnostics.SourceSwitch" switchValue="All">
<listeners>
<!-- Enable and configure listeners as desired to obtain trace messages. -->
<add name="LogFileListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="MdsTrace.log" traceOutputOptions="DateTime" />
<!-- <add name="EtwListener" type="System.Diagnostics.Eventing.EventProviderTraceListener, System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" initializeData="{F2A341B8-CA5F-49ad-B00C-A82D3FCF948B}"/> -->
<!-- <remove name="Default"/> -->
</listeners> </source>
</sources>
<trace autoflush="true" />
</system.diagnostics>
File name and path: The initializeData value is the name of the log file. This may be modified to another name or to include a desired path. If the path is not specified then the file will default to the web application directory path (where web.config resides).
Important Note: The service account for the MDS application pool must have write access to the log file location.
Logging level of detail: Table 1 below describes the categories of trace events that may be logged, sorted with the most important / critical events at the top. Table 2 below lists the valid settings for the logging
switchValue; this setting may be adjusted to produce the right amount of logging details to suit the situation.
Table 1 - MDS logging event typesEvent Type | Description |
Critical | a fatal error or application crash |
Error | a recoverable error |
Warning | a noncritical problem |
Information | an informational message |
Verbose | a debugging trace message |
Start | starting of a logical operation |
Stop | stopping of a logical operation |
Table 2 - SwitchValue settings for loggingSetting | What is logged: |
Off | nothing |
Error | errors only |
Warning | errors and warnings |
Information | errors, warnings, informational messages |
Verbose | “Information” plus additional debugging trace information including API requests and responses in XML format |
ActivityTracing | start and stop events only |
All | “Verbose” plus “ActivityTracing” |
Log setting recommendations:
- For normal operation, use the “Off” setting to avoid logging altogether or use the “Error” or “Warning” settings which will keep the log small while alerting administrators to problems.
- Use the “All” setting for support / troubleshooting situations.
- Use “ActivityTracing” for performance measurement or usage monitoring.
- Use “Information” only if prepared to periodically check and clean logs. The logs could get lengthy with this setting. This setting is helpful for tracking usage and usage patterns.
- Do not use “Verbose” or “All” under normal operating conditions as the volume of data logged will negatively affect performance.
Steps for creating a log file for product support: In situations where an unexpected error occurs and further diagnostics are required, it is helpful to create a log file that traces the events leading up to the problem along with the service requests and responses.
To produce a concise and helpful log file, perform the following steps.
Caution: Updating Web.config will cause the MDS application domain in IIS to recycle.
- If possible, stop the MDS application pool in IIS Manager (warning: do this only if the application can be taken off line).
- If possible, move or delete the current log file (if one already exists).
- Open the web.config file with a text editor.
Note By default the Web.config file is located in one of the following web application folders:- SQL Server 2008 R2:program_files\Microsoft SQL Server\Master Data Services\WebApplication
- SQL Server 2012:program_files\Microsoft SQL Server\110\Master Data Services\WebApplication
- Find the system.diagnostics section
- Change the switchValue to All or ActivityTracing and uncomment the log file line as shown in Turning on log file tracing section of this article.
- Use the “All” switchValue for error diagnostics.
- Use the “ActivityTracing” switchValue for performance diagnostics.
- The MdsTrace.log file name can be prefixed with a path if desired.
- If the application pool was previously stopped:
- Then, start the MDS application pool in IISb
- Else, wait for the log file to appear after some time and web application activity. The web application will periodically reload configuration settings from the file (should be within minutes).
- Reproduce the problem and perform the same actions or requests that led to the error.
- If you are able to stop application pool:
- Then:
- Stop the application pool.
- Retrieve the log file (may need to wait for processes to finish; there could be a delay after stopping the app pool)
- Else, open the log file with an editor that does not lock the file (like notepad.exe) and copy the relevant tracing messages.
- Open the web.config file with a text editor and change the switchValue back to Off or the prior value.
- Start the application pool if stopped.
Error Handling: All service operations return an array or collection of errors within the OperationResult object of a response message. When an error occurs, the error array is also serialized to XML and written to the web application log file for certain switchValue settings as described above.
Example of an API response error that has been written to the log file:
MDS Error: 0 :
<ArrayOfError xmlns="http://schemas.microsoft.com/sqlserver/masterdataservices/2009/09" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Error>
<Code>110003</Code>
<Context>
<FullyQualifiedName>Model1</FullyQualifiedName>
<Identifier>
<Id>00000000-0000-0000-0000-000000000000</Id>
<Name>Model1</Name> <InternalId>0</InternalId>
</Identifier>
<Type>Model</Type>
</Context>
<Description>The name already exists. Type a different name.</Description>
</Error>
</ArrayOfError>
DateTime=2009-12-10T20:48:05.6949548ZError object contents
Table 3 - As shown in the example above, each error includes the following data properties.Property | Description |
Code | The unique error number identifying the type of error |
Description | Localized error message text |
Context.FullyQualifiedName | The fully qualified name of the object involved in the error
Some names are only unique within their context. An entity would be qualified with a Model name prefix such as ModelName : EntityName. |
Context.Type | The type of object involved in the error |
Context.Identifier | The identifier of the object involved in the error |
Context.Identifier.Id | The unique GUID of the object, if specified or available |
Context.Identifier.Name | The name of the object, if specified or available |
Context.Identifier.InternalId | Deprecated – do not use |