LogViewerPanel

April 9, 2026 · View on GitHub

A slide-in panel that displays a filterable, searchable log of LogEntry items. Supports auto-scroll, level filtering, source filtering, copy, and clear operations.

Basic usage

<LogViewerPanel IsOpen="True"
               Title="Activity Log"
               PanelWidth="420" />

Properties

PropertyTypeDefaultDescription
IsOpenboolWhether the panel is visible
Titlestring"Activity Log"Panel title
AutoScrollbooltrueWhether the list auto-scrolls to new entries
ShowDebugEntriesboolfalseWhether Debug-level entries are shown
SearchTextstring?Text used to filter entries by message content
SelectedLevelFilterLogLevel?Level filter (null = show all levels)
SelectedSourceFilterstring?Source filter (null = show all sources)
MaxEntriesint5000Maximum number of entries to retain
PanelWidthdouble420Width of the slide-in panel
EntriesObservableCollection<LogEntry>Full collection of log entries
FilteredEntriesAvaloniaList<LogEntry>Filtered view of entries shown in the list
LevelFilterOptionsLogLevel?[]Available log level filter options
SourceFilterOptionsAvaloniaList<string?>Available source filter options

Events

EventDescription
ClosedRaised when the panel is closed
CopyAllRequestedRaised when the user requests all entries to be copied
CopyEntryRequestedRaised when the user requests a single entry to be copied

Opening/closing

Control panel visibility:

<LogViewerPanel IsOpen="{Binding IsLogViewerOpen}" />
logViewerPanel.Open();
logViewerPanel.Close();

Adding entries

Append log entries to the panel:

// Simple message
logViewerPanel.Append(LogLevel.Information, "Operation completed");

// Full entry
logViewerPanel.Append(new LogEntry
{
    Level = LogLevel.Error,
    Message = "Failed to connect",
    Source = "NetworkService",
    Details = "Timeout after 30 seconds"
});

Clearing entries

Remove all entries:

logViewerPanel.Clear();

Filtering

Filter by log level:

logViewerPanel.SelectedLevelFilter = LogLevel.Error;

Filter by source:

logViewerPanel.SelectedSourceFilter = "NetworkService";

Filter by text search:

<LogViewerPanel SearchText="{Binding SearchText}" />

Debug entries

Control whether debug entries are shown:

<LogViewerPanel ShowDebugEntries="True" />

Auto-scroll

Control automatic scrolling to new entries:

<LogViewerPanel AutoScroll="True" />

Max entries

Set the maximum number of entries to retain (older entries are removed):

<LogViewerPanel MaxEntries="10000" />

Panel width

Adjust the width of the slide-in panel:

<LogViewerPanel PanelWidth="600" />

Copy handling

Handle copy requests:

logViewerPanel.CopyAllRequested += (sender, e) =>
{
    var text = string.Join("\n", logViewerPanel.FilteredEntries.Select(x => x.ToString()));
    Clipboard.SetTextAsync(text);
};

logViewerPanel.CopyEntryRequested += (sender, entry) =>
{
    Clipboard.SetTextAsync(entry.ToString());
};

Example

// In your ViewModel
public class MainViewModel
{
    public LogViewerPanel LogViewer { get; } = new LogViewerPanel
    {
        Title = "Application Logs",
        MaxEntries = 10000
    };
    
    private void LogOperation(string message, LogLevel level = LogLevel.Information)
    {
        LogViewer.Append(level, message, Source: "MainViewModel");
    }
}

Pseudo-classes

The control applies pseudo-classes based on state:

  • :open - Applied when the panel is open
  • :hasEntries - Applied when there are filtered entries
  • :hasFilter - Applied when a filter is active

Use these for styling:

<Style Selector="LogViewerPanel:hasEntries">
    <Setter Property="Background" Value="White" />
</Style>