Skip to content

catalingavan/serilog-sinks-logbee

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serilog.Sinks

A collection of Serilog sinks that write events to logBee.net.

Request view

A Serilog sink used for non-web applications (Console applications, Worker services).

Log.Logger = new LoggerConfiguration()
    .WriteTo.LogBee(new LogBeeApiKey("_OrganizationId_", "_ApplicationId_", "https://api.logbee.net"))
    .CreateLogger();

try
{
    Log.Information("Hello from {Name}!", "Serilog");
}
catch(Exception ex)
{
    Log.Error(ex, "Unhandled exception");
}
finally
{
    // send the events to logBee.net
    Log.CloseAndFlush();
}

A Serilog sink used for web applications.

using Serilog;
using Serilog.Sinks.LogBee;
using Serilog.Sinks.LogBee.AspNetCore;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHttpContextAccessor();
builder.Services.AddControllersWithViews();

builder.Services.AddSerilog((services, lc) => lc
    .WriteTo.LogBee(
        new LogBeeApiKey("_OrganizationId_", "_ApplicationId_", "https://api.logbee.net"),
        services
    ));

var app = builder.Build();

app.MapGet("/", (ILogger<Program> logger) =>
{
    logger.LogInformation("My favourite cartoon is {Name}", "Futurama");
    return "Hello";
});

app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Home}/{action=Index}/{id?}");

// Important: register the LogBeeMiddleware() just before app.Run()
app.UseLogBeeMiddleware();

app.Run();

About

A sink for Serilog that writes events to logbee.net

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages