Workflow - Component - Developer Guide - Logging

Published on Wednesday, 9 November 2016

In this Article I'm going to explain how to Log information in your component.

There are times when you wish to log information to the Workflow Logs, for the Project the component is in.

[Install Drive]:\Program Files\Workflow\Logs\*.log

There are a number of log levels you can choose from.

Take the Create Log Entry as an example of which.

  • Info
  • Error
  • Debug
  • Fatal
  • Warn

We have a number of logging methods since we inherit from "AbstractSinglePathProcessComponent" => "AbstractSinglePathComponent" => "AbstractOrchestrationComponent"

namespace LogicBase.Core
{
    public abstract class AbstractOrchestrationComponent : IStorable, IOrchestrationComponent, IValidWithNofication, IValid
    {
        ...
        protected void LogDebug(IData data, string Debug);
        protected void LogError(IData data, Exception ex);
        protected void LogError(IData data, string message);
        protected void LogError(IData data, Exception ex, string message);
        protected void LogFatal(IData data, string message);
        protected void LogFatal(IData data, string message, Exception ex);
        protected void LogInfo(IData data, string Info);
        protected void LogWarn(IData data, string message);
        ...
    }
}

If we start typing Log into VS we will get autocompletion for the following methods.

WorkflowLogLevels

We could either call

base.LogError(data, "No rows found.");

Or base. isn't necessary.

LogError(data, "No rows found.");

Another thing I tend to do is add a Checkbox to the component and use that as a way to decide whether to log the information information. You could pass in a Debug flag.

Another option it to always log to Info then turn on the logging level in Workflow Explorer.

Protirus.png