Logging
While writting SDK there are several options of logging. Which one is used will determine how the logged information can be read later.
Message and LogMessage
In the case of SDK Actions, a RunCustomActionParams parameter is passed to the RunAsync method(or RunCustomActionWithoutContextParams in RunWithoutDocumentContextAsync method). In this object you can find two properties:
- Message - string property, value saved here will be stored in the logs on document history and if args.HasError is set to true this message will be displayed to the user on the Portal.
- LogMessage - string property, value saved here will be only stored in the logs on document history. To be able to see LogMessage on docment history you have to be in Admin mode. In Standard mode there is visible only Message.
public override async Task RunAsync(RunCustomActionParams args)
{
args.Message = "Message for user";
args.LogMessage = "Content of logs";
}
Action log in document history
PluginLogger
The second way of logging in extensions is by using PluginLogger. PluginLogger is accessible through the context object, in the CustomAction context is also in the args parameter.
PluginLogger have two methods:
- AppendInfo - Values logged using this method will always be saved
- AppendDebug - Values logged using this method will be saved only if in Designer Studio option Manual logs level is set to Debug
public override async Task RunAsync(RunCustomActionParams args)
{
args.Context.PluginLogger.AppendInfo("Info log");
args.Context.PluginLogger.AppendDebug("Debug log");
}
Loggs saved by PluginLogger can be viewed and configured in Designer Studio in the Plugin Packages tab. Logs and settings are stored separately for each extension.
Auto logs level
Automatic logs saves to log additional info with plugin configuration and context, you can control this logs with auto logs level setting
Available options
- None - Does not save any additional logs
- Error - Saves additional logs only on exceptions
- Init - Saves logs only on plugin initialization
- Always - Adds additional logs to every plugin method