A high-performance, WPF-based log viewer for PowerShell, specifically engineered to handle massive log files (up to 10 million lines) with minimal memory overhead and near-instant parsing. It mimics the functionality of the classic CMTrace utility while providing modern customization, multithreaded file tailing, and regex/keyword-based highlighting.
- Massive Log Support: Capable of seamlessly loading, retaining, and viewing up to 10,000,000 log lines in memory without crashing, trimming, or freezing the UI.
- Crash-Proof Bulk UI Updates: Implements a custom
ObservableRangeCollection<T>that properly suppresses individual notifications during bulk adds, preventing WPFItemsControlinconsistency exceptions and massive layout thrashing. - Multithreaded Performance: Uses a dedicated background Runspace with a highly tuned 10,000-item drain limit per 50ms tick to tail files, preventing UI freezes during massive log reads.
- WPF-Powered UI: Modern
DataGridinterface with strict item-level virtualization, ensuring smooth scrolling even with millions of log entries. - Throttled UI Rendering: Intelligent UI update throttling ensures the statistics panel recalculates at a maximum of 1Hz during continuous heavy tailing, keeping the interface buttery smooth.
- Optimized Initial Load: Real-time total line count updates without triggering heavy layout recalculations during the initial file flush, keeping the window draggable and responsive.
- Zero-Cost Timestamp Parsing: High-speed C# log parsing integrated directly into the script. Extracts timestamps via direct string slicing instead of
DateTime.TryParse, yielding a ~5x parsing speedup. - Customizable Highlighting: Define custom keywords and color schemes (Red, Orange, Yellow, Green, Blue, Purple, White) to instantly spot errors and warnings.
- Detail Formatting: Includes intelligent JSON formatting and delimiter splitting (comma, space, period) in the bottom detail panel for easier log analysis.
- Persistent Configuration: Automatically saves user settings, window state, and keyword preferences to an
.inifile inAppData.
- Optimized Tailer: Uses a
System.IO.StreamReaderwith a 64KB buffer andFileShare.ReadWriteto reliably tail active log files at maximum disk I/O speeds without locking them. - High-Capacity Memory Management: Pre-allocates 500,000 initial entries and dynamically scales up to 11 million items before trimming, drastically reducing array resizing overhead and GC pressure.
- O(1) Auto-Scrolling: Caches the WPF
ScrollViewerreference and usesScrollToEnd()instead ofScrollIntoView(), bypassing expensive visual tree realization and layout calculations. - Smart Filtering Bypass: Automatically skips the C# filtering logic and injects raw batches directly into the UI collection if no level filters are active.
- Zero-GC Pressure: Uses
StringBuilderand efficient string slicing (avoiding unnecessary concatenations and date parsing) to parse logs with minimal garbage collection. - Mouse-Wheel Smoothing: Features custom
PreviewMouseWheelhandling to provide granular, "slow" scrolling for precise log investigation.
- Requirements: PowerShell 5.1 or later (64-bit host required for large memory allocations).
- Run: Simply execute the script in a PowerShell host capable of rendering WPF (e.g.,
powershell.exeorpwsh.exe). - Opening Logs: Use
File > Open...to select a.logor.txtfile.
The application allows full customization of:
- Visuals: Font family, font size, and window layout.
- Highlighting: Add, remove, or modify keyword/color mappings in the Settings menu.
- Formatting: Toggle JSON beautification or add custom delimiters for parsing complex message strings.
- 10 Million Line Capacity:
MaxRetainedEntriesincreased to 10,000,000.InitialCapacityincreased to 500,000 to prevent constant array resizing during massive file loads. - WPF Crash Fix: Completely rewrote
ObservableRangeCollectionto fire a singleResetevent after bulk additions, fixing the "ItemsControl is inconsistent with its items source" crash when ingesting hundreds of thousands of lines per second. - 5x Faster Parsing: Replaced
DateTime.TryParsewith directSubstringextraction for CMTrace timestamps. - High-Throughput I/O: Increased
StreamReaderbuffer size to 64KB to minimize system calls during initial file reads. - Instant Auto-Scroll: Replaced
DataGrid.ScrollIntoView()with cachedScrollViewer.ScrollToEnd()for O(1) scrolling performance. - UI Thread Protection: Tuned
MaxDrainPerTickto 10,000 and the refresh timer to 50ms, ensuring the UI thread is never starved even if the background parser ingests 50,000+ logs/sec.
Developed for high-performance systems administration and rapid troubleshooting of massive log files.