Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serilog.Sinks.AspNetCore.App.SignalR

Serilog.Sinks.AspNetCore.App.SignalR

NuGet Version NuGet Downloads Target Frameworks

An easy-to-use Serilog sink that enables logging to SignalR in ASP.NET Core applications.

Installation

dotnet add package Serilog.Sinks.AspNetCore.App.SignalR

Quick Start

Default hub

The simplest setup. A hub is provided out of the box — no custom hub class required. Log events are streamed to clients by calling a named method (e.g. ReceiveEvent) on all connected clients.

builder.Services.AddDefaultSerilogHub();
builder.Services.AddSerilog((serviceProvider, loggerConfiguration) =>
    loggerConfiguration.WriteTo.SignalR(serviceProvider, "ReceiveEvent"));

app.MapDefaultSerilogHub("/logs");

Typed hub

Use when you need full control over how events are sent. Targets a hub you define and accepts a delegate that gives you direct access to the hub context, formatted message, and raw LogEvent.

builder.Services.AddSerilogHub<MyHub>();
builder.Services.AddSerilog((serviceProvider, loggerConfiguration) =>
    loggerConfiguration.WriteTo.SignalR<MyHub>(serviceProvider,
        (context, message, logEvent) =>
            context.Clients.All.SendAsync("ReceiveEvent", message, logEvent)));

app.MapHub<MyHub>("/logs");

Documentation

About

An easy-to-use Serilog sink that enables logging to SignalR in ASP.NET Core applications.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages