All Projects → nblumhardt → serilog-sinks-browserhttp

nblumhardt / serilog-sinks-browserhttp

Licence: Apache-2.0 license
Serilog sink for client-side Blazor, with matching ASP.NET Core server relay

Programming Languages

C#
18002 projects
powershell
5483 projects

Projects that are alternatives of or similar to serilog-sinks-browserhttp

Sitko.Core
Sitko.Core is a set of libraries to help build .NET Core applications fast
Stars: ✭ 46 (+27.78%)
Mutual labels:  serilog, blazor
PoShLog
🔩 PoShLog is PowerShell cross-platform logging module. It allows you to log structured event data into console, file and much more places easily. It's built upon great C# logging library Serilog - https://serilog.net/
Stars: ✭ 108 (+200%)
Mutual labels:  serilog
blazor.jwttest
Quick test using JWT authentication for a blazor hosted (Client/Serverside) app with API and Authentication.
Stars: ✭ 30 (-16.67%)
Mutual labels:  blazor
Flexor
Blazor flexbox components
Stars: ✭ 23 (-36.11%)
Mutual labels:  blazor
BlazorQuiz
Simple quiz using Blazor.NET and Webassembly
Stars: ✭ 42 (+16.67%)
Mutual labels:  blazor
BlazorHealthApp
Example application ported from Angular 2 to Blazor
Stars: ✭ 37 (+2.78%)
Mutual labels:  blazor
CodeIndex
A Code Index Searching Tools Based On Lucene.Net
Stars: ✭ 28 (-22.22%)
Mutual labels:  blazor
BlazorLazyLoad
BlazorLazyLoad is a concept of assembly lazy load in Blazor WASM application.
Stars: ✭ 16 (-55.56%)
Mutual labels:  blazor
fast-blazor
Blazor component library for FluentUI. Microsoft's official lightweight wrapper around the FluentUI Web Components for use with .NET 6.0 Blazor applications
Stars: ✭ 928 (+2477.78%)
Mutual labels:  blazor
Blazaco
A Blazor Component utilizing the Monaco editor by Microsoft
Stars: ✭ 23 (-36.11%)
Mutual labels:  blazor
AspNetCore.Client
On Build client generator for asp.net core projects
Stars: ✭ 14 (-61.11%)
Mutual labels:  blazor
Analogy.LogViewer
A customizable Log Viewer with ability to create custom providers. Can be used with C#, C++, Python, Java and others
Stars: ✭ 172 (+377.78%)
Mutual labels:  serilog
smart-blazor
Blazor UI Components & Examples
Stars: ✭ 32 (-11.11%)
Mutual labels:  blazor
FlappyBlazorBird
FlapPyBird transcoded to Blazor
Stars: ✭ 54 (+50%)
Mutual labels:  blazor
Blazorade-Teams
A Blazor component library that is designed to be used when building applications for Microsoft Teams.
Stars: ✭ 29 (-19.44%)
Mutual labels:  blazor
awesome-blazor-browser
A Blazor WebAssembly app for browsing the "Awesome Blazor" resources.
Stars: ✭ 155 (+330.56%)
Mutual labels:  blazor
TelephoneDirectory
microservices-> .net 6, golang - Docker, Ocelot, RabbitMq, MassTransit, mssql, postgresql, elasticsearch, kibana, jwt
Stars: ✭ 40 (+11.11%)
Mutual labels:  serilog
BlazorAuthenticationSample
A sample showing some of the ASP.NET Core Blazor authentication features (also some testing...) 🚀
Stars: ✭ 78 (+116.67%)
Mutual labels:  blazor
vditor-blazor
📝 A markdown web editor based on Vditor and Blazor.
Stars: ✭ 51 (+41.67%)
Mutual labels:  blazor
EmbeddedBlazorContent
Library to load embedded content files (js and css) from Blazor libraries in server-side Blazor mode.
Stars: ✭ 39 (+8.33%)
Mutual labels:  blazor

Serilog.Sinks.BrowserHttp Build status

Note: this project is currently at the proof-of-concept stage, and may eat your laundry.

A Serilog sink for client-side Blazor that posts batched events using the browser's HTTP stack. These can be sent to any remote HTTP endpoint, including the app's origin server. A companion package, Serilog.AspNetCore.Ingestion, is also published from this repository, and can be used to relay events from the client to Serilog running in the ASP.NET Core server process.

Getting started

In a Blazor client (WASM) app, first install Serilog.Sinks.BrowserHttp:

dotnet add package Serilog.Sinks.BrowserHttp

The sink is enabled using WriteTo.BrowserHttp:

var builder = WebAssemblyHostBuilder.CreateDefault(args);
Log.Logger = new LoggerConfiguration()
    .MinimumLevel.ControlledBy(levelSwitch)
    .WriteTo.BrowserConsole()
    .WriteTo.BrowserHttp($"{builder.HostEnvironment.BaseAddress}ingest")
    .CreateLogger();

Log.Information("Hello, browser!");

Events will be POSTed in newline-delimited JSON batches to the given URL. See Serilog.Formatting.Compact for a description of the JSON schema that is used.

Server-side relay for ASP.NET Core

To use the server-side relay in an ASP.NET Core app that uses Serilog, install Serilog.AspNetCore.Ingestion:

dotnet add package Serilog.AspNetCore.Ingestion

Then, add UseSerilogIngestion() to the app builder in Startup.cs:

app.UseSerilogIngestion();

The client app should be configured with LoggingLevelSwitch so that the server can control the client's logging level. An endpoint address is not required. For example:

// In a Blazor WASM Program.cs file
var builder = WebAssemblyHostBuilder.CreateDefault(args);
var levelSwitch = new LoggingLevelSwitch();
Log.Logger = new LoggerConfiguration()
    .MinimumLevel.ControlledBy(levelSwitch)
    .WriteTo.BrowserHttp($"{builder.HostEnvironment.BaseAddress}ingest", controlLevelSwitch: levelSwitch)
    .CreateLogger();

Log.Information("Hello, browser!");

See the /samples directory in this repository for a working end-to-end example.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].