Serilog.Sinks.SignalR.Core 0.1.2

Sink for SignalR.Core.

Install-Package Serilog.Sinks.SignalR.Core -Version 0.1.2
dotnet add package Serilog.Sinks.SignalR.Core --version 0.1.2
<PackageReference Include="Serilog.Sinks.SignalR.Core" Version="0.1.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Serilog.Sinks.SignalR.Core --version 0.1.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

serilog-sinks-signalr-core

A Serilog' sink that writes event to SignalR Hub.

Inspired by serilog-sink-signalr, I decided to rewrite it because this latter is not fully compatible with Microsoft.AspNetCore.SignalR.Core.

Usage and configuration

The hub to use with the Sink must be strong-typed and must extend the interface ISerilogHub. An example is as follows

public SerilogHub : Serilog.Sinks.SignalR.Core.Interfaces.ISerilogHub
{}

An example sink' setup is as follows

[...]

var hub = ServiceProvider.GetService<IHubContext<SerilogHub, ISerilogHub>>();

Log.Logger = new LoggerConfiguration()
    .WriteTo.SignalR(
        hub,
        formatProvider: new CustomFormatProvider(),
        groups: new [] { "group1", },
        userIds: new [] { "user2", },
        excludedConnectionIds: new [] { "1", }
    )
    .CreateLogger();

[...]

app.UseSignalR(conf => {
    conf.MapHub<SerilogHub>("/log");
})

Receive the log events

In the client code, subscribe to the PushEventLog method.

[...]

var connection = new HubConnectionBuilder()
    .WithUrl("http://localhost:8080/log")
    .Build()

connection.On<string>("PushEventLog", (string message) => {
    Console.WriteLine(message);
});

[...]

Options

In the package it's also available an abstract base hub (BaseSerilogHub), that can be extended and that gives some utility functions (like SubscribeToGroup). Hence, feel free to extend that class if you want.

serilog-sinks-signalr-core

A Serilog' sink that writes event to SignalR Hub.

Inspired by serilog-sink-signalr, I decided to rewrite it because this latter is not fully compatible with Microsoft.AspNetCore.SignalR.Core.

Usage and configuration

The hub to use with the Sink must be strong-typed and must extend the interface ISerilogHub. An example is as follows

public SerilogHub : Serilog.Sinks.SignalR.Core.Interfaces.ISerilogHub
{}

An example sink' setup is as follows

[...]

var hub = ServiceProvider.GetService<IHubContext<SerilogHub, ISerilogHub>>();

Log.Logger = new LoggerConfiguration()
    .WriteTo.SignalR(
        hub,
        formatProvider: new CustomFormatProvider(),
        groups: new [] { "group1", },
        userIds: new [] { "user2", },
        excludedConnectionIds: new [] { "1", }
    )
    .CreateLogger();

[...]

app.UseSignalR(conf => {
    conf.MapHub<SerilogHub>("/log");
})

Receive the log events

In the client code, subscribe to the PushEventLog method.

[...]

var connection = new HubConnectionBuilder()
    .WithUrl("http://localhost:8080/log")
    .Build()

connection.On<string>("PushEventLog", (string message) => {
    Console.WriteLine(message);
});

[...]

Options

In the package it's also available an abstract base hub (BaseSerilogHub), that can be extended and that gives some utility functions (like SubscribeToGroup). Hence, feel free to extend that class if you want.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.1.2 170 9/1/2019
0.1.1 73 9/1/2019
0.1.0 69 9/1/2019