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();
        }
Example #2
0
        static void SetupLogger()
        {
            _baseLogger = new LoggerConfiguration()
                          .WriteTo.Console()
                          .WriteTo.File(@"log\MassTransit.log", rollingInterval: RollingInterval.Day)
                          .CreateLogger();

            SerilogLogWriterFactory.Use(_baseLogger);
        }
Example #3
0
        static void ConfigureSerilog()
        {
            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         .WriteTo.Console()
                         .CreateLogger();

            // Configure Topshelf Logger
            SerilogLogWriterFactory.Use(Log.Logger);
        }
Example #4
0
        private static int Main(string[] args)
        {
            var logger = new LoggerConfiguration()
                         .WriteTo.ColoredConsole().CreateLogger();

            Log.Logger = logger;

            SerilogLogWriterFactory.Use(logger);

            return((int)HostFactory.Run(x => x.Service <ActivityService>()));
        }
 /// <summary>
 /// Configures Topshelf to use Serilog for logging, using the given <see cref="LoggerConfiguration"/> to create loggers.
 /// </summary>
 public static void UseSerilog(this HostConfigurator configurator, LoggerConfiguration loggerConfiguration)
 {
     SerilogLogWriterFactory.Use(loggerConfiguration);
 }
 /// <summary>
 /// Configures Topshelf to use Serilog for logging, using the global <see cref="Log.Logger"/> instance to derive its loggers.
 /// </summary>
 public static void UseSerilog(this HostConfigurator configurator)
 {
     SerilogLogWriterFactory.Use();
 }
Example #7
0
 /// <summary>
 /// Configures Topshelf to use Serilog for logging, using the given root logger <see cref="ILogger"/> to create loggers.
 /// </summary>
 public static void UseSerilog(this HostConfigurator configurator, ILogger rootLogger)
 {
     SerilogLogWriterFactory.Use(rootLogger);
 }