Meziantou.AspNetCore.Components.LogViewer 2.0.3

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Meziantou.AspNetCore.Components.LogViewer --version 2.0.3
                    
NuGet\Install-Package Meziantou.AspNetCore.Components.LogViewer -Version 2.0.3
                    
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="Meziantou.AspNetCore.Components.LogViewer" Version="2.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Meziantou.AspNetCore.Components.LogViewer" Version="2.0.3" />
                    
Directory.Packages.props
<PackageReference Include="Meziantou.AspNetCore.Components.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 Meziantou.AspNetCore.Components.LogViewer --version 2.0.3
                    
#r "nuget: Meziantou.AspNetCore.Components.LogViewer, 2.0.3"
                    
#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 Meziantou.AspNetCore.Components.LogViewer@2.0.3
                    
#: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=Meziantou.AspNetCore.Components.LogViewer&version=2.0.3
                    
Install as a Cake Addin
#tool nuget:?package=Meziantou.AspNetCore.Components.LogViewer&version=2.0.3
                    
Install as a Cake Tool

Meziantou.AspNetCore.Components.LogViewer

A Blazor component for displaying and analyzing log entries with support for filtering, highlighting, and interactive exploration.

Features

  • Display log entries with customizable formatting
  • Syntax highlighting for URLs, quoted text, and custom patterns
  • Flexible timestamp formats (full datetime, relative time, hidden)
  • Interactive log details with table and JSON views
  • Line numbers for easy reference
  • Log level styling with distinct visual indicators
  • Clickable URLs in log messages
  • Multi-line log support with expandable details
  • ANSI color and style rendering (16-color, 256-color, and truecolor SGR sequences)

Usage

Basic Example

@page "/logs"
@using Meziantou.AspNetCore.Components

<LogViewer Entries="@logEntries" />

@code {
    private List<LogEntry> logEntries = new()
    {
        new LogEntry
        {
            Timestamp = DateTimeOffset.UtcNow,
            Message = "Application started",
            LogLevel = LogLevel.Information
        },
        new LogEntry
        {
            Timestamp = DateTimeOffset.UtcNow.AddSeconds(1),
            Message = "Processing request",
            LogLevel = LogLevel.Debug
        },
        new LogEntry
        {
            Timestamp = DateTimeOffset.UtcNow.AddSeconds(2),
            Message = "An error occurred",
            LogLevel = LogLevel.Error
        },
    };
}

Advanced Example with Configuration

@page "/logs"
@using Meziantou.AspNetCore.Components

<LogViewer
    Entries="@logEntries"
    TimestampDisplayFormat="TimestampDisplayFormat.DateTimeThenRelativeTime"
    ShowLineNumbers="true"
    LogHighlighters="@highlighters" />

@code {
    private ILogHighlighter[] highlighters = new ILogHighlighter[]
    {
        new UrlLogHighlighter(),
        new QuoteLogHighlighter()
    };

    private List<LogEntry> logEntries = new()
    {
        new LogEntry
        {
            Timestamp = DateTimeOffset.UtcNow,
            Message = "Check out https://example.com for more info",
            LogLevel = LogLevel.Information
        },
        new LogEntry
        {
            Timestamp = DateTimeOffset.UtcNow.AddSeconds(5),
            Message = "User 'admin' logged in",
            LogLevel = LogLevel.Information
        },
    };
}

Log Entries with Structured Messages

@code {
    private List<LogEntry> logEntries = new()
    {
        new LogEntry
        {
            Timestamp = DateTimeOffset.UtcNow,
            LogLevel = LogLevel.Information,
            Message = new
            {
                Text = "Request completed with details",
                UserId = 123,
                Endpoint = "/api/users",
                Duration = TimeSpan.FromMilliseconds(245),
                Headers = new Dictionary<string, string>
                {
                    { "User-Agent", "Mozilla/5.0" },
                    { "Content-Type", "application/json" }
                }
            }
        },
    };
}

When Message is a string, it is displayed as highlighted text. For non-string Message values, the structured payload is rendered inline and can be viewed as either a table or JSON.

ANSI-formatted Messages

LogViewer parses ANSI SGR escape sequences embedded in string messages and renders the corresponding foreground/background colors and text styles.

new LogEntry
{
    Timestamp = DateTimeOffset.UtcNow,
    LogLevel = LogLevel.Information,
    Message = "\u001b[1;33mwarning\u001b[0m \u001b[38;2;100;200;50mcustom color\u001b[0m",
}

Hierarchical / Nested Logs

A LogEntry can contain child entries via the Children property, with an unlimited number of levels. Each entry is independently collapsible. Set Expanded = true on an entry to make it start expanded (the default is collapsed). The toggle controls nested children.

@code {
    private List<LogEntry> logEntries = new()
    {
        new LogEntry
        {
            Timestamp = DateTimeOffset.UtcNow,
            Message = "Handling request",
            LogLevel = LogLevel.Information,
            Expanded = true,
            Children = new List<LogEntry>
            {
                new LogEntry
                {
                    Timestamp = DateTimeOffset.UtcNow,
                    Message = "Querying database",
                    LogLevel = LogLevel.Debug,
                    Children = new List<LogEntry>
                    {
                        new LogEntry
                        {
                            Timestamp = DateTimeOffset.UtcNow,
                            Message = "Executing query",
                            LogLevel = LogLevel.Trace,
                        },
                    },
                },
            },
        },
    };
}

Line numbers count every entry in the tree (including collapsed children), so the numbers stay stable when you expand or collapse nodes.

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.  net11.0 is compatible. 
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
2.0.11 74 11/13/2026
2.0.10 57 11/8/2026
2.0.9 135 10/28/2026
2.0.8 66 10/21/2026
2.0.7 73 10/16/2026
2.0.6 100 9/11/2026
2.0.5 98 9/6/2026
2.0.4 98 8/29/2026
2.0.3 103 8/16/2026
2.0.2 103 8/9/2026
2.0.1 107 7/17/2026
2.0.0 113 7/5/2026
1.0.29 104 6/28/2026
1.0.28 112 6/13/2026
1.0.27 98 6/13/2026
1.0.26 107 5/31/2026
1.0.25 156 5/14/2026
1.0.24 161 5/11/2026
1.0.23 147 4/25/2026
1.0.22 163 3/29/2026
Loading failed