Platform Logging
PoshUI includes a robust logging framework designed to assist with troubleshooting and audit trails in enterprise environments.
Log Infrastructure
The framework generates logs from both the PowerShell modules and the C# execution engine.
PowerShell Module Logs
Captured during the initialization and serialization phases. These logs help debug issues with module loading, cmdlet execution, and UI definition building.
UI Engine Logs
Generated by PoshUI.exe during the rendering and execution phases. These logs are critical for diagnosing:
- JSON/AST parsing errors
- WPF rendering issues
- ScriptBody execution failures
- Refresh script errors in dashboards
Format: CMTrace Compatible
All PoshUI logs are written in a structured format compatible with CMTrace.exe (part of the Microsoft Endpoint Configuration Manager toolkit).
- Component Tracking: Logs identify which part of the framework (Module, Engine, Workflow) generated the entry.
- Severity Levels: Entries are categorized as
Information,Warning, orError. - Timestamps: Precise millisecond-level timestamps for performance analysis.
Default Log Locations
By default, logs are stored relative to the script being executed:
| Module | Default Path |
|---|---|
| Wizard | .\Logs\Wizard_<ScriptName>_<Timestamp>.log |
| Dashboard | .\Logs\Dashboard_<ScriptName>_<Timestamp>.log |
| Workflow | .\Logs\Workflow_<ScriptName>_<Timestamp>.log |
Configuring Logging
Custom Log Paths
For Workflow modules, you can specify a custom log directory during initialization:
New-PoshUIWorkflow -Title "Setup" -LogPath "C:\Internal\Logs"Log Levels
Logging is always enabled. In-depth debug information can be enabled by setting the $VerbosePreference or using the -Verbose switch on PoshUI cmdlets.
Best Practices
- Monitor Errors: Always check the logs if a UI fails to launch or a script body behaves unexpectedly.
- Log Retention: PoshUI does not automatically rotate logs. For long-running automated systems, implement a basic cleanup task for the
Logsfolder. - Sensitive Data: PoshUI attempts to redact sensitive information from logs, but always review log content before sharing it outside your organization.
Next: Theming
