Datapolis Process System SDK
Trace Logging
This section describes logging mechanism in Datapolis Process System
Introduction
Windows SharePoint Services contains the Unified Logging Service (ULS) that is responsible for writing logs to either Windows events or trace log. More details about Configuring WSS logging settings are here. Datapolis Process System implements the trace logs functionality by the class WBLogger. The logs are written to the same files as it does WSS (...\15\Logs\). Datapolis Process System logs are come under the same rules as the standard WSS ones. It means that the selection of least-critical log level that is recorded can be managed from Central Administration. Just one thing must be remembered, that Datapolis Process System logs are assigned to the Workflow Infrastructure category. So only this category settings impact on Datapolis Process System tracing. Tracing logs during execution of an activity is the common best practice.
Note
Example
The first example below shows how to trace logging on two levels: the lowest one (Verbose) that is it just indicates the starting/ending of the activity and the highest one (Unexpected) it collects information when some exception is happen.
protected
override
ActivityExecutionStatus ExecuteBody(ActivityExecutionContext c)
{
this
.Logger.Verbose(
"Starting ExecuteBody function of the create list activity"
);
try
.CreateList();
}
catch
(Exception e)
.ErrorStatus = e.Message;
.ReturnListUrl =
string
.Empty;
.Logger.Unexpected(
"An error occured during creation a new list"
, e);
"Ending ExecuteBody function of the create list activity"
return
ActivityExecutionStatus.Closed;
The second example below shows how to trace information about the activity that would be helpful during future analyzing. Such as info can be gathered on Medium level.
private
void
CreateList()
SPSecurity.RunWithElevatedPrivileges(
delegate
using
(var site =
new
SPSite(
.ParentWebUrl))
(var parentWeb = site.OpenWeb())
.Logger.Medium(
"Parameters: ParentWebUrl: '{0}', ListTitle: '{1}', ListDescription: '{2}', ListTemplate: '{3}', IsQuickLuanch: '{4}'"
,
.ParentWebUrl,
.ListTitle,
.ListDescription,
.ListTemplate,
.IsQuickLuanch);
var spListTemplate = WBWebHelper.GetListTemplate(parentWeb,
.ListTemplate);
if
(spListTemplate ==
null
)
var msg =
.Format(
"The list that title should be: '{0}' cannot be created as the template list (InternalName: '{1}') has not be found, ParentWebUrl: '{2}'"
.ParentWebUrl);
.ErrorStatus = msg;
.ReturnListUrl = msg;
.Logger.Unexpected(msg);
;
var listId = parentWeb.Lists.Add(
.ListDescription, spListTemplate);
(listId == Guid.Empty)
"The list that title should be: '{0}' could not be created as the list Id is empty, ParentWebUrl: '{1}', ListTemplate: '{2}'"
else
var list = parentWeb.Lists[listId];
list.OnQuickLaunch =
.IsQuickLuanch;
list.Update();
.ReturnListUrl = parentWeb.Url + list.DefaultViewUrl;
.ErrorStatus =
"0"
"The list that title is: '{0}' has been created successfully, ReturnListUrl: '{1}', ErrorStatus: '{2}'"
.ReturnListUrl,
.ErrorStatus);
});