Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
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();
}
}
}