Logging in Workflow Server
Setting up logging​
Starting with version 2.3, logging is built into Workflow Server. Logging to the following targets is supported:
- console
- IDE Debugger Output
- files
- Windows Event Log
Windows Event Log is only available if Workflow Server is running as a Windows service.
Three types of messages are logged:
- Info - informational message
- Debug - debug message
- Error - error message
The logging subsystem is configured on the Dashboard tab. Here you can choose which types of messages will be logged and which targets will be used. Logging to files has advanced settings:
- File name & path - the base name for the log file and the path to it. This setting is required. You can specify either a relative or an absolute path.
- Max file size (bytes) - the maximum file size in bytes. The file size is not restricted if the value is not specified. If the specified size is exceeded, the next log file will be created.
- Rolling interval - the time interval through which the next log file is created.
- Max number of files - the maximum number of saved log files.
tip
Please note that if you start Workflow Server as a Service and use logging to files, then you better specify the full path to the file and create a folder for logs in advance in order to avoid errors due to the lack of service's rights to create folders.
Log access​
Workflow Server includes an interface to access log files. This interface can only be used if you are using file logging.
Using this interface, you can find and download all log files for a certain period and see recent entries in the latest log file. A double click on a line in a grid with a log opens a window for viewing a log entry.
Logging through Workflow API​
In WorkflowAPI there are 3 methods LogInfo
, LogError
and LogDebug
. You can use them to write to the log using HTTP
requests. Parameters of these methods are
described here.
Logging from Code Actions​
Workflow Server initializes the workflowRuntime.Logger
with its internal logger. Since the WorkflowRuntime
instance
is available in any Code Action, you can easily write to the log. The WorkflowRuntime
instance is passed to the Code
Actions as a parameter with the name runtime
. Thus, you can write to the log with the following code:
runtime.Logger.Debug(string messageTemplate, params object[] propertyValues);
runtime.Logger.Debug(string messageTemplate);
runtime.Logger.Debug(Exception exception, string messageTemplate);
runtime.Logger.Debug(Exception exception, string messageTemplate, params object[] propertyValues);
runtime.Logger.Error(Exception exception, string messageTemplate, params object[] propertyValues);
runtime.Logger.Error(string messageTemplate);
runtime.Logger.Error(Exception exception, string messageTemplate);
runtime.Logger.Error(string messageTemplate, params object[] propertyValues);
runtime.Logger.Info(string messageTemplate, params object[] propertyValues);
runtime.Logger.Info(Exception exception, string messageTemplate, params object[] propertyValues);
runtime.Logger.Info(Exception exception, string messageTemplate);
runtime.Logger.Info(string messageTemplate);
Besides, WorkflowRuntime
has the following three methods:
runtime.LogInfo(string message, Dictionary<string, string> parameters);
runtime.LogDebug(string message, Dictionary<string, string> parameters);
runtime.LogError(string message, Dictionary<string, string> parameters);