public async Task Execute(ILoggingBuilder builder, LoggerItemConfiguration configuration) { //反序列化特定配置 var innerConfiguration = JsonSerializerHelper.Deserialize <ConsoleConfiguration>(JsonSerializerHelper.Serializer(configuration.ConfigurationObj)); //绑定提供方 builder.AddConsole((opt) => { if (innerConfiguration != null) { opt.DisableColors = innerConfiguration.DisableColors; opt.IncludeScopes = innerConfiguration.IncludeScopes; } }); //配置级别过滤 foreach (var filterItem in configuration.LogLevels) { builder.AddFilter <ConsoleLoggerProvider>(filterItem.Key, filterItem.Value); } //配置其他未指定目录的最低级别 builder.AddFilter <ConsoleLoggerProvider>((level) => { if (level < configuration.DefaultMinLevel) { return(false); } return(true); }); await Task.FromResult(0); }
public async Task Execute(ILoggingBuilder builder, LoggerItemConfiguration configuration) { //反序列化特定配置 var innerConfiguration = JsonSerializerHelper.Deserialize <ExceptionLessConfiguration>(JsonSerializerHelper.Serializer(configuration.ConfigurationObj)); _exceptionLessProvider.Key = innerConfiguration.Key; if (!string.IsNullOrEmpty(innerConfiguration.ServiceUri)) { _exceptionLessProvider.ServiceUri = innerConfiguration.ServiceUri; } builder.AddProvider(_exceptionLessProvider); //配置级别过滤 foreach (var filterItem in configuration.LogLevels) { builder.AddFilter <ExceptionLessProvider>(filterItem.Key, filterItem.Value); } //配置其他未指定目录的最低级别 builder.AddFilter <ExceptionLessProvider>((level) => { if (level < configuration.DefaultMinLevel) { return(false); } return(true); }); await Task.FromResult(0); }
public async Task Execute(ILoggingBuilder builder, LoggerItemConfiguration configuration) { //反序列化特定配置 var innerConfiguration = JsonSerializerHelper.Deserialize <ApplicationInsightsConfiguration>(JsonSerializerHelper.Serializer(configuration.ConfigurationObj)); //绑定提供方 builder.AddApplicationInsights(innerConfiguration.Key, (opt) => { opt.IncludeScopes = innerConfiguration.IncludeScopes; opt.TrackExceptionsAsExceptionTelemetry = innerConfiguration.TrackExceptionsAsExceptionTelemetry; }); //配置级别过滤 foreach (var filterItem in configuration.LogLevels) { builder.AddFilter <ApplicationInsightsLoggerProvider>(filterItem.Key, filterItem.Value); } //配置其他未指定目录的最低级别 builder.AddFilter <ApplicationInsightsLoggerProvider>((level) => { if (level < configuration.DefaultMinLevel) { return(false); } return(true); }); await Task.FromResult(0); }
public async Task Execute(ILoggingBuilder builder, LoggerItemConfiguration configuration) { builder.AddProvider(_commonLogProvider); //配置级别过滤 foreach (var filterItem in configuration.LogLevels) { builder.AddFilter <CommonLogProvider>(filterItem.Key, filterItem.Value); } //配置其他未指定目录的最低级别 builder.AddFilter <CommonLogProvider>((level) => { if (level < configuration.DefaultMinLevel) { return(false); } return(true); }); await Task.FromResult(0); }