// public static ILoggingBuilder AddCustomLogger(this ILoggingBuilder builder) => builder.AddCustomLogger(new CustomLoggerConfiguration(),); public static ILoggingBuilder AddCustomLogger(this ILoggingBuilder builder, Action <CustomLoggerConfiguration> configure, IElasticSearchHelper esHelper) { var config = new CustomLoggerConfiguration(); configure(config); return(builder.AddCustomLogger(config, esHelper)); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("app"); builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); builder.Services.AddLocalization(); var host = builder.Build(); var jsInterop = host.Services.GetRequiredService <IJSRuntime>(); var result = await jsInterop.InvokeAsync <string>("blazorCulture.get"); if (result != null) { var culture = new CultureInfo(result); CultureInfo.DefaultThreadCurrentCulture = culture; CultureInfo.DefaultThreadCurrentUICulture = culture; } else { CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CurrentUICulture = CultureInfo.GetCultureInfo("en"); } builder.Services.AddLogging(configure => { CustomLoggerConfiguration customLoggerConfiguration = builder.Configuration.GetSection("CustomLoggerConfiguration").Get <CustomLoggerConfiguration>(); configure.AddProvider(new CustomLoggerProvider( customLoggerConfiguration )); }); await builder.Build().RunAsync(); }
public static ILoggerFactory AddCustomLogger(this ILoggerFactory loggerFactory, Action <CustomLoggerConfiguration> configure) { var config = new CustomLoggerConfiguration(); configure(config); return(loggerFactory.AddCustomLogger(config)); }
public static ILoggingBuilder AddColorConsoleLogger(this ILoggingBuilder builder, Action <CustomLoggerConfiguration> configure) { var config = new CustomLoggerConfiguration(); configure(config); return(builder.AddColorConsoleLogger(config)); }
public IConfiguration LoadSettings() { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()); var redis = LoadRedisSettings(); if (redis != null) { builder.AddRedisConfig(new CancellationToken(), options => { options.RedisConfig = redis; options.Path = AppSettingsLocation; options.Optional = true; options.ReloadOnChange = true; options.OnReload = () => { if (!(_readyCheck?.Ready ?? false)) { return; } Console.WriteLine($"Settings have been updated..."); _logger?.Information($"Settings have been updated..."); StopServices(); Environment.Exit(0); }; }); } builder.AddJsonFile(AppSettingsLocation, optional: false, reloadOnChange: false); _configuration = builder.Build(); _dbSettings = _configuration.GetSection("DbSettings").Get <List <DbSettings> >(); _consoleLogging = _configuration.GetSection("ConsoleLogging").Get <CustomLoggerConfiguration>(); return(_configuration); }
public CustomLoggerProvider(CustomLoggerConfiguration config) { _config = config; }
public CustomLogger(string name, CustomLoggerConfiguration config) { _name = name; _config = config; }
public CustomLoggerProvider(CustomLoggerConfiguration config, IElasticSearchHelper esHelper) => (_config, _esHelper) = (config, esHelper);
public static ILoggingBuilder AddCustomLogger(this ILoggingBuilder builder, CustomLoggerConfiguration config, IElasticSearchHelper esHelper) { builder.AddProvider(new CustomLoggerProvider(config, esHelper)); return(builder); }
public CustomLogger(string name, CustomLoggerConfiguration config, IElasticSearchHelper esHelper) => (_name, _config, _esHelper) = (name, config, esHelper);
public static ILoggerFactory AddCustomLogger(this ILoggerFactory loggerFactory, CustomLoggerConfiguration config) { loggerFactory.AddProvider(new CustomLoggerProvider(config)); return(loggerFactory); }
public static ILoggingBuilder AddColorConsoleLogger(this ILoggingBuilder builder, CustomLoggerConfiguration config) { builder.AddProvider(new CustomLoggerProvider(config)); return(builder); }
public CustomLogger(string name, CustomLoggerConfiguration config) => (_name, _config) = (name, config);