ModelingEvolution.Blazor.LogViewer 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ModelingEvolution.Blazor.LogViewer --version 1.0.0
                    
NuGet\Install-Package ModelingEvolution.Blazor.LogViewer -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ModelingEvolution.Blazor.LogViewer" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ModelingEvolution.Blazor.LogViewer" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="ModelingEvolution.Blazor.LogViewer" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ModelingEvolution.Blazor.LogViewer --version 1.0.0
                    
#r "nuget: ModelingEvolution.Blazor.LogViewer, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ModelingEvolution.Blazor.LogViewer@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ModelingEvolution.Blazor.LogViewer&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=ModelingEvolution.Blazor.LogViewer&version=1.0.0
                    
Install as a Cake Tool

ModelingEvolution.Blazor.LogViewer

A reusable Blazor component for viewing logs from processes and Docker containers in real-time using XtermBlazor terminal.

CI NuGet

Features

  • Real-time log streaming from processes and Docker containers
  • Multiple log source support with source switching
  • Separate stdout/stderr views with toggle
  • Copy to clipboard functionality
  • ANSI color support via XtermBlazor
  • Circular buffer with configurable max lines
  • Extensible architecture for custom log sources

Installation

dotnet add package ModelingEvolution.Blazor.LogViewer

Quick Start

1. Add required resources to your App.razor or _Host.cshtml:


<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" />
<link href="_content/MudBlazor/MudBlazor.min.css" rel="stylesheet" />


<link rel="stylesheet" href="_content/ModelingEvolution.XTermBlazor/XtermBlazor.min.css" />

<script src="_content/MudBlazor/MudBlazor.min.js"></script>
<script src="_content/ModelingEvolution.XTermBlazor/XtermBlazor.min.js"></script>

2. Add MudBlazor providers to your layout:

<MudThemeProvider IsDarkMode="true" />
<MudPopoverProvider />
<MudDialogProvider />
<MudSnackbarProvider />

3. Add the namespace to _Imports.razor:

@using ModelingEvolution.Blazor.LogViewer
@using MudBlazor

4. Use the LogViewer component:

<LogViewer Source="@_logSource" Height="500" />

@code {
    private ProcessLogSource _logSource;
    private event Action<string, StreamType>? _onOutput;

    protected override void OnInitialized()
    {
        _logSource = new ProcessLogSource(
            "My Process",
            handler => _onOutput += handler,
            handler => _onOutput -= handler);
    }
}

Log Sources

ProcessLogSource

Observes an externally-managed process via event subscription:

// Your process wrapper raises events
public event Action<string, StreamType>? OnOutput;

// Create a ProcessLogSource that subscribes to those events
var source = new ProcessLogSource(
    name: "My Process",
    subscribe: handler => OnOutput += handler,
    unsubscribe: handler => OnOutput -= handler,
    maxLines: 10_000);

// Start observing
source.StartObserving();

// Emit events from your process
OnOutput?.Invoke("Hello from stdout", StreamType.StandardOutput);
OnOutput?.Invoke("Error message", StreamType.ErrorOutput);

// Signal completion when process exits
source.SignalCompleted();

DockerLogSource

Streams logs from an already-running Docker container:

var source = new DockerLogSource(
    name: "My Container",
    containerIdOrName: "my-container-id",
    maxLines: 10_000);

source.StartObserving();
// Logs are automatically streamed from the container

MockLogSource

For testing and demos:

var source = new MockLogSource("Test");
source.StartObserving();

// Emit test lines
source.EmitLine("Standard output line");
source.EmitLine("Error line", isError: true);

Multi-Source Support

Display multiple log sources with a dropdown selector:

<LogViewer Sources="@_sources" Height="600" OnSourceChanged="HandleSourceChanged" />

@code {
    private List<ILogSubscriptionSource> _sources = new()
    {
        new MockLogSource("Source 1"),
        new MockLogSource("Source 2"),
        new MockLogSource("Source 3")
    };

    private void HandleSourceChanged(ILogSubscriptionSource source)
    {
        Console.WriteLine($"Switched to: {source.Name}");
    }
}

Parameters

Parameter Type Default Description
Source ILogSubscriptionSource? null Single log source
Sources List<ILogSubscriptionSource>? null Multiple log sources
Height int 600 Terminal height in pixels
MaxLines int 10,000 Maximum lines per buffer
Theme TerminalOptions? null XtermBlazor theme options
ToolButtons RenderFragment? null Custom toolbar buttons
OnSourceChanged EventCallback<ILogSubscriptionSource> - Callback when source changes

Custom Tool Buttons

Add custom buttons to the toolbar:

<LogViewer Source="@_source" Height="500">
    <ToolButtons>
        <button @onclick="HandleClear">Clear</button>
        <button @onclick="HandleExport">Export</button>
    </ToolButtons>
</LogViewer>

Custom Log Source

Implement ILogSubscriptionSource for custom log sources:

public class MyCustomLogSource : ILogSubscriptionSource
{
    public string Name => "Custom";
    public LogSourceStatus Status { get; private set; }
    public event Action<LogSourceStatus>? OnStatusChanged;

    public void StartObserving() { /* ... */ }
    public void StopObserving() { /* ... */ }
    public IDisposable Subscribe(Action<string> onLine, LogMode mode) { /* ... */ }
    public void Dispose() { /* ... */ }
}

Example Application

The repository includes a complete example application demonstrating:

  • Process logs with CliWrap
  • Docker container logs
  • Multi-source switching

Run the example:

cd examples/LogViewerExample
dotnet run

License

MIT

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.1 96 12/22/2025
1.1.0 93 12/22/2025
1.0.3 106 12/20/2025
1.0.1 98 12/20/2025
1.0.0 108 12/20/2025