Using logging
  • Updated on 16 Apr 2019
  • 5 minutes to read
  • Print
  • Dark
    Light

Using logging

  • Print
  • Dark
    Light

Summary

The  Decisions server logs are stored at C:\ProgramFiles\Decisions\Decisions Services Manager\Logs

Utilizing these logs can be extremely important to debugging code that you've written. But before you can use these log effectively to debug your code, you need to know how your code can interact with these logs. The following describes how the different levels at which you can write logs and how to control with levels are written.

For a more in depth logging overview see documentation here: https://documentation.decisions.com/logging-overview/

Logging Levels

Messages can be written to these logs at numerous levels which include the following:

  • Info
  • Debug
  • Warn
  • Error
  • Fatal

Logging at the Information and Debug levels will dramatically increase the size of log files over time, and negatively impact performance. These levels should only be turned on when necessary for troubleshooting, or for demonstrations.
The levels that are actually written to the log file can be control via the Settings.xml file which is located at C:\Program Files\Decisions\Decisions Services Manager\Settings.xml . In this file, the settings for enabling/disables these log levels are located in the following tags.

 <loginfo>true</loginfo><logdebug>true</logdebug><logwarn>true</logwarn><logerror>true</logerror><logfatal>true</logfatal>

Writing to the Logs

To write to the Decisions logs from your code, you first need to instantiate a  DecisionsFramework.Log . With this, you will be able to write to the logs at the different levels describes above.

Many of these level have the same input data. Here is a list of the pieces of input data used by these levels and how that data is used in the logs.

  • object sourceObject : The logger will attempt to do a .ToString() on the object and write that string in your log entry.
  • string message : This is the main part of your log message. You can write custom text here to signal where in your code you are. You can only merge in error message that have been caught.
  • params object[] arguments : This allows you input parameter into your log message. For example, you could write a log entry like this: LogDebug(this,"{0} {1} {2} is today", "Thursday", "Jan 10th", "2013");

Below is comments sample code that explains the different levels. The attached project contains this code and can be compiled and deployed as a steps to allow you to test different combinations with the logging levels.

 using DecisionsFramework;
using System;
using DecisionsFramework.Design.Flow;
 
namespace DecisionsLoggingSample
{
  [AutoRegisterMethodsOnClass(true, "SampleSteps", "Logging", RegisterForAgents = true)]
  public class LoggingExample
  {
    //Note: the name (e.g. "Example Log") you provide here will prefix the logs
    //that you write with this instance of Log.
    //For example an info level log written with this Log will look like the following:
    //[Info],09 Jan 2013 16:39:11,Thread 23,Exmaple Log [Message]:Info level message
    private static Log log = new Log("Example Log");
 
    public static void writeToDecisionsLogs()
    {       
      //create an exception we can use in logging
      try
      {
        int zero = 0;
        int number = 5 / zero;
      }
      catch (Exception ex)
      {
        //The Info, Debug and Warn levels are very similar.
        //They take the same inputs and using one instead of the other
        //just changes the level at which the log is written.
        //Currently the first (object) parameter is not used in these levels and can be set to null.
        //Looks like: [Info],14 Jan 2013 11:12:05,Thread 17,Example Log [Message]:Info level message. Today is Thursday Jan 10th 2013
        log.LogInfo(null, "Info level message. Today is {0} {1} {2}", "Thursday", "Jan 10th", "2013");
         
        //Looks like: [Debug],14 Jan 2013 11:12:05,Thread 17,Example Log [Message]:Debug level message
        log.LogDebug(null, "Debug level message");
 
        //Looks like: [Warn],14 Jan 2013 11:12:05,Thread 17,Example Log [Message]:Warm level message
        log.LogWarn(null, "Warm level message");
 
 
 
        //LogError can be used in three ways. This level does use the object input parameter and so can be set to null or to a value;
        //Looks like: [Error],14 Jan 2013 11:12:05,Thread 17,Example Log [Message]:Error level message
        log.LogError(null, "Error level message");
 
        //Looks like: [Error],14 Jan 2013 11:12:05,Thread 17,Example Log [Message]:Attempted to divide by zero. [Exception]:System.DivideByZeroException: Attempted to divide by zero.  at DecisionsLoggingSample.LoggingExample.writeToDecisionsLogs()
        log.LogError(null, ex);
         
        //Looks like: [Error],14 Jan 2013 11:12:05,Thread 17,Example Log [Message]:Error level message [Exception]:System.DivideByZeroException: Attempted to divide by zero.  at DecisionsLoggingSample.LoggingExample.writeToDecisionsLogs()
        log.LogError(null, ex, "Error level message");
 
 
 
        //Currently the first (object) parameter is not used in these levels and can be set to null.
        //Looks like: [Fatal],14 Jan 2013 11:12:05,Thread 17,Example Log [Message]:Fatal level message [Exception]:System.DivideByZeroException: Attempted to divide by zero.  at DecisionsLoggingSample.LoggingExample.writeToDecisionsLogs()
        log.LogFatal(null, "Fatal level message", ex);
 
        //Looks like: [Fatal],14 Jan 2013 11:12:05,Thread 17,Example Log [Message]:Fatal level message
        log.LogFatal(null, "Fatal level message");
      }
    }
  }
}

Accessing Logs

The Decisions logs can be accessed in two ways.

You can open the CSV file directly. This file is stored at  C:\Program Files\Decisions\Decisions Services Manager\Logs\Decisions.CONTROLINSTANCE.log.csv .

Alternatively, you can view the logs from the Decisions portal by navigating to System > Administration > System Tools > Logging .

2018-06-28_100550.jpg

Fatal and error-level errors are also logged as Windows events for monitoring by external tools.

Logging Types

Assembly Types Parser AppDomain.log This is the log for Assembly Types that are Parsed in the App Domain. This is generally not enabled, but seems like that the Configuration was set to Log to its own file.
DecisionsServiceHost.exe.*.log This file contains the Log for the Main Service (i.e. the Windows Service that is Installed)
DecisionsServiceHost.exe.Usage.*.csv This File contains the Usage Log, Memory details, counts etc. for Host Service
DecisionsServiceHost.exe.UsageDetails.*.log This File contains the Usage Log, Memory details, counts etc. for Host Service (Individual Calls and Additional Details)
DecTail.exe Custom tailing application.
Primary.*.log Log messages from the Decisions Service Host Manager. - Primary Instance
Primary.Usage.*.csv Minute-by-minute logs of Flow executions, API calls, job executions, etc. - Primary Instance
Primary.UsageDetails.*.log Minute-by-minute counts of individual API calls, Flows runs, etc. - Primary Instance
View_Usage_CSV.ps1 & View_Usage_Text.ps1 These are powershell scripts to open the usage logs in powershell.
WebSite_HUI.log & WebSite_decisions.log These are more the construction of the website within IIS rather that Decisions thats hosted within. These are depreciated in newer versions.
Was this article helpful?