public static void ConfigureLoggingDefaults(SerilogConfigParameters parameters) { var systemName = parameters.Type?.Name ?? parameters.SystemName; var serilogConfigRequest = new SerilogConfigRequest(); serilogConfigRequest.Configurators.Add(new ElasticSinkOptions(parameters.ElasticHosts)); serilogConfigRequest.Configurators.Add(new FileSinkOptions(parameters.FolderPath + $@"\{systemName}.log")); ConfigureLogging(systemName, serilogConfigRequest); }
public static void ConfigureLogging(string systemName, SerilogConfigRequest request) { LoggerConfiguration logConfig = new LoggerConfiguration() .MinimumLevel.Debug() .Enrich.FromLogContext() .Enrich.WithProperty("System", systemName); if (request.IsVerbose) { logConfig = logConfig.MinimumLevel.Verbose(); } foreach (ISerilogConfigurator configurator in request.Configurators) { logConfig = configurator.Configure(logConfig); } Log.Logger = logConfig.CreateLogger(); }