Development Logging - rpapub/WatchfulAnvil GitHub Wiki
How to Add Temporary Logging to the Temp Folder in UiPath Workflow Analyzer Rules
Overview
When developing custom Workflow Analyzer rules for UiPath, debugging and logging can help track execution flow and identify issues. A simple way to temporarily log information is by writing to a file in the system's temporary folder.
Steps to Add Logging to the Temp Folder
1. Determine the Temporary Folder Path
Use Path.GetTempPath()
to retrieve the system's temporary folder path.
using System.IO;
string tempLogPath = Path.Combine(Path.GetTempPath(), "WorkflowAnalyzer.log");
2. Append Log Messages
Use File.AppendAllText()
to add log messages without overwriting previous entries.
File.AppendAllText(tempLogPath, "🚀 Starting project-wide analysis...\n");
3. Implement Logging in Your Rule
Modify your rule's inspection logic to include debugging messages.
Example:
private InspectionResult InspectProjectForShouldStop(IProjectModel projectModel, Rule configuredRule)
{
string logPath = Path.Combine(Path.GetTempPath(), "ShouldStopActivityRule.log");
File.AppendAllText(logPath, "🚀 Checking project workflows...\n");
foreach (var workflow in projectModel.Workflows)
{
File.AppendAllText(logPath, $"🔍 Checking workflow: {workflow.DisplayName}\n");
if (workflow.Root == null)
{
File.AppendAllText(logPath, $"⚠️ Workflow {workflow.DisplayName} has NO root!\n");
continue;
}
if (ContainsShouldStopActivity(workflow.Root))
{
File.AppendAllText(logPath, $"✅ Found 'ShouldStop' in {workflow.DisplayName}\n");
return new InspectionResult { HasErrors = false };
}
}
File.AppendAllText(logPath, "❌ No 'ShouldStop' found in any workflow!\n");
return new InspectionResult { HasErrors = true, RecommendationMessage = configuredRule.RecommendationMessage, ErrorLevel = TraceLevel.Error };
}
4. Clean Up Logging (Optional)
If logs are temporary, consider removing them after debugging:
if (File.Exists(logPath))
{
File.Delete(logPath);
}
Summary
By using Path.GetTempPath()
and File.AppendAllText()
, you can easily log debugging messages while analyzing workflows. This helps diagnose issues and verify rule logic before deployment.