Configuring Business Logging Policy for an Operation
The Business Logging policy lets you log header and message information for all messages sent to or from operations in a service. This can optionally include fault messages, depending on your configuration. Messages are recorded in the SQL Server BusinessLog database.
The Business Logging policy is completely transparent to client applications and to the operations that the service runs.
The Business Logging policy includes properties from the DCS Context class. The policy incorporates the Environment and Organization properties. For more information, see DCS Context.
Business Log Policy Prerequisites
To let you store business logging information, you should select the Business Log Database option when you install DCS so that the business log database is installed.
Note
If you omitted the Business Log Database when you installed DCS, you can run the setup.exe installer again, and on the Program Maintenance page, select the Modify option. You can then select the Business Log Database component and install it.
Configuring the Service
The Business Logging policy exposes a single property, enableBusinessLogging, which is a Boolean flag that determines whether to enable the logging functionality. As with all operation policies, you can choose the direction of messages to log.
To define Business Logging policy for an single oOperation
In the DCS Management Services Console, expand the Policy Management node, expand the service that contains the required operation, and then expand Operations.
In the left pane, click the operation that you want to configure, right-click the operation, and then click New.
In the Edit Policy dialog box, in the Policy Type list, click Microsoft.ConnectedIndustry.ServiceModel.Application.Policy.BusinessLogPolicy.
In the Direction list, select the message direction on which to specify the policy.
-
Note
To enable Fault message logging in the policy, you must set a policy for both Fault and Response messages. If you only specify the Fault direction, the logging policy does not log messages. Use either the wildcard (*) property setting or two business logging policies, configured to log Response and Fault messages respectively.
Set the enableBusinessLog property to True to enable logging, and then click OK.
You must add an element to the configurationStrings section of the service configuration file to enable the service to connect to the business logging database. The following example shows the element that provides the connection string for a local database instance.
<connectionStrings>
<!-- common connection strings -->
...
<add name="businessLog" connectionString="Server=(local);Initial Catalog=businessLog;Integrated Security=Yes;" providerName="System.Data.SqlClient"/>
...
</connectionStrings>
Implementing a Custom Business Logging Database
You can implement a custom business logging database to enable additional functionality. However, the built-in business logging policy requires the logging database to have a table named BusinessLog, with the structure shown in the following table.
Column Name |
SWL Data Type |
Restrictions |
---|---|---|
LogTimestamp |
datetime |
not null |
ServiceUri |
nvarchar(1000) |
not null |
SoapAction |
nvarchar(200) |
not null |
MessageDirection |
int |
not null |
ConversationId |
nvarchar(100) |
not null |
SessionId |
uniqueidentifier |
null |
User |
nvarchar(64) |
null |
Environment |
nvarchar(10) |
null |
PlantId |
nchar(6) |
null |
HoldingId |
nchar(6) |
null |
BusinessUnitId |
nchar(6) |
null |
OrganizationalUnitId |
nchar(6) |
null |
BusinessChannel |
nvarchar(10) |
null |
OperationDate |
smalldatetime |
null |
ReferenceDate |
smalldatetime |
null |
AccountingDate |
smalldatetime |
null |
Culture |
nchar(5) |
null |
Properties |
XML(.) |
null |
OperationId |
nvarchar(50) |
null |
MessageBody |
ntext |
not null |
Note
The values stored in the columns from SessionId to Culture come directly from properties defined in the service Context object.