Datapolis Process System SDK

Search:

Contents
:
IndexBookmarkPrint
Home > Trace Logging

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

Unexpected and Monitorable log levels are usually used for error-prone and warning situations appropriately. The rest ones (High, Medium and Verbose) are used to gather any information depending on the significance of the traced info. For more details see WBLogLevel

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
    {
        this.CreateList();
    }
    catch (Exception e)
    {
        this.ErrorStatus = e.Message;
        this.ReturnListUrl = string.Empty;
        this.Logger.Unexpected("An error occured during creation a new list", e);
    }
 
    this.Logger.Verbose("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(this.ParentWebUrl))
        {
            using (var parentWeb = site.OpenWeb())
            {
                this.Logger.Medium("Parameters: ParentWebUrl: '{0}',  ListTitle: '{1}',  ListDescription: '{2}', ListTemplate: '{3}', IsQuickLuanch: '{4}'",
                this.ParentWebUrl, this.ListTitle, this.ListDescription, this.ListTemplate, this.IsQuickLuanch);
 
                var spListTemplate = WBWebHelper.GetListTemplate(parentWeb, this.ListTemplate);
                if (spListTemplate == null)
                {
                    var msg = string.Format("The list that title should be: '{0}' cannot be created as the template list (InternalName: '{1}') has not be found, ParentWebUrl: '{2}'",
                    this.ListTitle, this.ListTemplate, this.ParentWebUrl);
                    this.ErrorStatus = msg;
                    this.ReturnListUrl = msg;
                    this.Logger.Unexpected(msg);
                    return;
                }
 
                var listId = parentWeb.Lists.Add(this.ListTitle, this.ListDescription, spListTemplate);
                if (listId == Guid.Empty)
                {
                    var msg = string.Format("The list that title should be: '{0}' could not be created as the list Id is empty, ParentWebUrl: '{1}', ListTemplate: '{2}'",
                    this.ListTitle, this.ParentWebUrl, this.ListTemplate);
                    this.ErrorStatus = msg;
                    this.ReturnListUrl = msg;
                    this.Logger.Unexpected(msg);
                    return;
                }
                else
                {
                    var list = parentWeb.Lists[listId];
                    list.OnQuickLaunch = this.IsQuickLuanch;
                    list.Update();
                    this.ReturnListUrl = parentWeb.Url + list.DefaultViewUrl;
                    this.ErrorStatus = "0";
                    this.Logger.Medium("The list that title is: '{0}' has been created successfully, ReturnListUrl: '{1}', ErrorStatus: '{2}'", this.ListTitle, this.ReturnListUrl, this.ErrorStatus);
                }
            }
        }
    });
}