Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
39 lines (34 sloc) 1.26 KB
namespace StarterKit.Service.Configuration
{
using MassTransit.SerilogIntegration;
using Serilog;
using System;
using System.Diagnostics;
using Topshelf.Logging;
public class TopshelfSerilogBootstrapper
{
public TopshelfSerilogBootstrapper()
{
// Common Initial
var loggerConfiguration = new LoggerConfiguration()
.Enrich.FromLogContext()
.Enrich.WithEnvironmentUserName()
.Enrich.WithMachineName()
.MinimumLevel.Is(Serilog.Events.LogEventLevel.Debug)
.MinimumLevel.Override("MassTransit", Serilog.Events.LogEventLevel.Warning)
.WriteTo.Console()
.WriteTo.AzureDocumentDB(
"https://<yourcosmodb>.documents.azure.com:443/",
Environment.GetEnvironmentVariable("CosmoDbAuthKey"),
"Logs",
"StarterKitDoSomeWork",
timeToLive: 86400);
// Common Final
Log.Logger = loggerConfiguration.CreateLogger();
// Configure Topshelf Logger
SerilogLogWriterFactory.Use(Log.Logger);
// MassTransit to use Serilog
SerilogLogger.Use();
}
}
}