private static void SetupGraylog(GraylogOptions graylogOptions) { if (graylogOptions != null) { var graylogConfig = new GraylogSinkConfiguration { GraylogTransportType = GetGraylogTransportTypeFromString(graylogOptions.GrayLogProtocol), Host = graylogOptions.GrayLogHost, Port = graylogOptions.GrayLogPort, UseSecureConnection = graylogOptions.UseSecureConnection, UseAsyncLogging = graylogOptions.UseAsyncLogging, RetryCount = graylogOptions.RetryCount, RetryIntervalMs = graylogOptions.RetryIntervalMs, MaxUdpMessageSize = graylogOptions.MaxUdpMessageSize }; LoggerConfiguration = LoggerConfiguration.WriteTo.Graylog(graylogConfig); } }
public static void ConfigureLog(string applicationPath) { var logFile = string.Format(LogDefinition.LogFile, DateTime.Today.ToShortDateString().Replace("/", string.Empty)); var loggerConfiguration = new LoggerConfiguration() .MinimumLevel.Debug() .MinimumLevel.Override("Microsoft", LogEventLevel.Information) .Enrich.FromLogContext() .WriteTo.File($"{applicationPath}/{LogDefinition.LogFolder}/{logFile}"); if (!String.IsNullOrEmpty(LogDefinition.GrayLogHost)) { var graylogConfig = new GraylogSinkConfiguration { GraylogTransportType = GetGraylogTransportTypeFromString(LogDefinition.GrayLogProtocol), Host = LogDefinition.GrayLogHost, Port = LogDefinition.GrayLogPort, UseSecureConnection = LogDefinition.UseSecureConnection, UseAsyncLogging = LogDefinition.UseAsyncLogging, RetryCount = LogDefinition.RetryCount, RetryIntervalMs = LogDefinition.RetryIntervalMs, MaxUdpMessageSize = LogDefinition.MaxUdpMessageSize }; loggerConfiguration = loggerConfiguration.WriteTo.Graylog(graylogConfig); } if (!String.IsNullOrEmpty(LogDefinition.SeqLogServerHost)) { loggerConfiguration = loggerConfiguration.WriteTo.Seq(LogDefinition.SeqLogServerHost); } if (!String.IsNullOrEmpty(LogDefinition.SqliteDatabase)) { loggerConfiguration = loggerConfiguration.WriteTo.SQLite($"{applicationPath}/{LogDefinition.LogFolder}/{LogDefinition.SqliteDatabase}"); } Serilog.Log.Logger = loggerConfiguration.CreateLogger();; IdentityModelEventSource.ShowPII = true; }