public RunServices() { ServiceName = "Sport News Service"; configuration = GetConfiguration(); serviceProvider = GetServiceProvider(configuration); logger = GetLogger(configuration, serviceProvider); }
public ActionResultFaultlessExecutionService(FaultlessExecution.Abstractions.IFaultlessExecutionService faultlessExecutionService, Microsoft.Extensions.Logging.ILogger <ActionResultFaultlessExecutionService> logger) { _faultlessExecutionService = faultlessExecutionService; _faultlessExecutionService.LogErrors = false;//bypass the built in error log, we'll log the errors ourself _logger = logger; }
public RunServices() { ServiceName = "Precious Metal Service"; configuration = GetConfiguration(); serviceProvider = GetServiceProvider(configuration); logger = GetLogger(configuration, serviceProvider); }
public NuGetClient(Microsoft.Extensions.Logging.ILogger <NuGetClient> logger) { _providers = new List <Lazy <INuGetResourceProvider> >(); _providers.AddRange(Repository.Provider.GetCoreV3()); _providers.Add(new Lazy <INuGetResourceProvider>(() => new PackageMetadataResourceV3Provider())); this._logger = logger; }
/// <summary> /// Startup Constructor /// </summary> /// <param name="configuration"></param> /// <param name="hostingEnvironment"></param> /// <param name="logger"></param> public Startup(IConfiguration configuration, IHostingEnvironment hostingEnvironment, Microsoft.Extensions.Logging.ILogger <Startup> logger ) { _hostingEnvironment = hostingEnvironment; _logger = logger; _logger.LogInformation($"Start {nameof(Startup)}"); try { _builder = new ConfigurationBuilder() .SetBasePath(_hostingEnvironment.ContentRootPath) .AddJsonFile($"appsettings.json", optional: false, reloadOnChange: true); } catch (Exception exception) { _logger.LogError($"Exception in {nameof(Startup)}:{exception.Message}"); } _logger.LogInformation($"Exit {nameof(Startup)}"); Configuration = _builder.Build(); }
public AccountController(UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, Microsoft.Extensions.Logging.ILogger <AccountController> logger) { this.userManager = userManager; this.signInManager = signInManager; this.logger = logger; }
public TelegramBotController(ITelegramBotClient botClient, IConfiguration configuration, IOrderService orderService, IJuiceService juiceService, ILogger <TelegramBotController> logger) { this.telegramBot = botClient ?? throw new ArgumentNullException(nameof(botClient)); Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); this.orderService = orderService ?? throw new ArgumentNullException(nameof(orderService)); this.juiceService = juiceService ?? throw new ArgumentNullException(nameof(juiceService)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public UserDetailsController(IHostingEnvironment hostingEnvironment, ILogger <UserDetailsController> logger, IHttpContextAccessor httpContextAccessor) { this.HostingEnvironment = hostingEnvironment; this.Logger = logger; var identity = httpContextAccessor.HttpContext.User.Identity as ClaimsIdentity; this.emailAddress = identity.Claims.FirstOrDefault(x => x.Type == "emails")?.Value; }
public CatalogInvalidator(Microsoft.Extensions.Logging.ILogger <CatalogInvalidator> logger, CacheOptions config, ICatalogScanStore store, ICatalogReader reader) { this._log = logger; this.store = store; var period = TimeSpan.FromSeconds(config.InvalidationCheckSeconds); _scanTimer = new Timer(state => Run(), null, period, period); this.reader = reader; }
public LetsEncryptChallengeApprovalMiddleware( Microsoft.AspNetCore.Http.RequestDelegate next , Microsoft.Extensions.Logging.ILogger <LetsEncryptChallengeApprovalMiddleware> logger // ,IPersistenceService persistenceService ) { _next = next; _logger = logger; // _persistenceService = persistenceService; }
public static void StartSubscriber(IWebHost host) { using (var scope = host.Services.CreateScope()) { var provider = scope.ServiceProvider; var subscriptionOptions = provider.GetService <IOptions <SubscriberOptions> >(); Microsoft.Extensions.Logging.ILogger <Program> logger = provider.GetService <Microsoft.Extensions.Logging.ILogger <Program> >(); var readSourceName = subscriptionOptions.Value.TopicName; if (string.IsNullOrWhiteSpace(readSourceName)) { throw new Exception("Event store subcriber cannot be started."); } var repository = provider.GetService <IReadModelRepository <ReadPointer> >(); var readPointer = repository.GetAll() .FirstOrDefault(x => x.SourceName == readSourceName); if (readPointer == null) { readPointer = new ReadPointer { SourceName = readSourceName, Position = -1, CreatedOn = DateTime.Now, LastModifiedOn = DateTime.Now, PublicId = Guid.NewGuid() }; Task.Run(() => { try { repository.AddAsync(readPointer); } catch (Exception e) { logger.LogError(e, e.Message); throw; } }).Wait(); } var eventSubscriber = provider.GetService <IEventStoreSubscriber>(); if (eventSubscriber.IsStarted) { return; } var position = readPointer.Position < 0 ? null : readPointer.Position; eventSubscriber.Start(position); } }
public DiagnosticsMonitor(IServiceProvider services, MonitoringSourceConfiguration sourceConfig) { _services = services; _sourceConfig = sourceConfig; IOptions <ContextConfiguration> contextConfig = _services.GetService <IOptions <ContextConfiguration> >(); _dimValues = new List <string> { contextConfig.Value.Namespace, contextConfig.Value.Node }; _metricLoggers = _services.GetServices <IMetricsLogger>(); _logger = _services.GetService <ILogger <DiagnosticsMonitor> >(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, Microsoft.Extensions.Logging.ILogger <Startup> logger) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.ConfigureExceptionHandler(logger); app.UseMvc(); app.UseDefaultFiles(); app.UseStaticFiles(); }
/// <summary> /// Uses Microsoft Console Logger. /// </summary> /// <returns></returns> /// <remarks>Microsoft logger is a logging abstraction, the default sinks are very extremely basic and usually farm out /// to other systems to get more features. Output timestamp by default https://github.com/aspnet/Logging/issues/483#issuecomment-320574792 /// </remarks> public static Microsoft.Extensions.Logging.ILogger <T> UseConsoleLogger <T>() { ILoggerFactory loggerFactory = LoggerFactory.Create(builder => { builder.AddConsole(configure => configure.TimestampFormat = "MM/dd/yyyy hh:mm:ss.fff tt"); builder.AddFilter <ConsoleLoggerProvider>(null, LogLevel.Information); }); Microsoft.Extensions.Logging.ILogger <T> logger = loggerFactory.CreateLogger <T>(); return(logger); }
public LinuxServiceHost( Microsoft.Extensions.Configuration.IConfiguration configuration, Microsoft.Extensions.Hosting.IHostingEnvironment environment, Microsoft.Extensions.Logging.ILogger <LinuxServiceHost> logger, Microsoft.Extensions.Hosting.IApplicationLifetime appLifetime, ICommonService commonService) { this.configuration = configuration; this.logger = logger; this.appLifetime = appLifetime; this.environment = environment; this.commonService = commonService; }
public CommonSampleService( Microsoft.Extensions.Configuration.IConfiguration configuration , Microsoft.Extensions.Logging.ILogger <CommonSampleService> logger , MyConfig config , Microsoft.Extensions.Options.IOptions <SmtpConfig> smtp ) { System.Console.WriteLine(smtp.Value.Server); this.m_configuration = configuration; this.m_logger = logger; System.Console.WriteLine(config.A); System.Console.WriteLine(config.B); logger.LogInformation("Class instatiated"); }
public NuRepository(List <Lazy <INuGetResourceProvider> > providers, Uri repositoryUrl, Microsoft.Extensions.Logging.ILogger <NuGetClient> logger) { this.providers = providers; this.repositoryUrl = repositoryUrl; this._logger = logger; PackageSource packageSource = new PackageSource(repositoryUrl.AbsoluteUri); _sourceRepository = new SourceRepository(packageSource, providers); _cacheContext = new SourceCacheContext(); var httpSource = _sourceRepository.GetResource <HttpSourceResource>(); _regResource = _sourceRepository.GetResource <RegistrationResourceV3>(); ReportAbuseResourceV3 reportAbuseResource = _sourceRepository.GetResource <ReportAbuseResourceV3>(); _metadataSearch = new PackageMetadataResourceV3(httpSource.HttpSource, _regResource, reportAbuseResource); _versionSearch = new RemoteV3FindPackageByIdResource(_sourceRepository, httpSource.HttpSource); this._loggerAdapter = new NuGetLoggerAdapter <NuGetClient>(logger); }
private static INotificationManager CreateNotifier(Microsoft.Extensions.Logging.ILogger <Program> logger, EmailConfig emailConfig, ServiceProvider serviceProvider) { logger.LogInformation("Creating notifier for {0} ...", emailConfig.Domain); INotificationManager notifier; try { notifier = serviceProvider.GetService <INotificationManager>(); } catch (Exception e) { logger.LogError(e, "Cannot create notifier."); throw; } logger.LogInformation("Notifier created."); return(notifier); }
/// <summary> /// Uses Serilog Debug Logger. /// </summary> /// <returns></returns> /// <remarks>https://benfoster.io/blog/serilog-best-practices/</remarks> public static Microsoft.Extensions.Logging.ILogger <T> UseSerilogToDebug <T>() { ILoggerFactory loggerFactory = LoggerFactory.Create(builder => { builder.AddSerilog ( Log.Logger = new LoggerConfiguration() .MinimumLevel.Verbose() .WriteTo.Debug ( outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff} [{Level}] {Message}{NewLine}{Exception}" ) .CreateLogger() ); }); Microsoft.Extensions.Logging.ILogger <T> logger = loggerFactory.CreateLogger <T>(); return(logger); }
public AppUserManager(IUserStore <AppUser> store, IOptions <IdentityOptions> optionsAccessor, IPasswordHasher <AppUser> passwordHasher, IEnumerable <IUserValidator <AppUser> > userValidators, IEnumerable <IPasswordValidator <AppUser> > passwordValidators, ILookupNormalizer keyNormalizer, IdentityErrorDescriber errors, IServiceProvider services, Microsoft.Extensions.Logging.ILogger <UserManager <AppUser> > logger, PasswordChangeNotificationMailer passwordChangeNotificationMailer, TwoFactorChangeNotificationMailer twoFactorChangeNotificationMailer) : base(store, optionsAccessor, passwordHasher, userValidators, passwordValidators, keyNormalizer, errors, services, logger) { this._passwordChangeNotificationMailer = passwordChangeNotificationMailer; this._twoFactorChangeNotificationMailer = twoFactorChangeNotificationMailer; }
public FormulaController(Microsoft.Extensions.Logging.ILogger <FormulaController> logger, ApplicationDbContext context) { _context = context; _logger = logger; }
public BeatModsClient(HttpClientFactory clientFactory, IMemoryCache cache, JsonSerializerOptions options, IVersionProvider versionProvider, Microsoft.Extensions.Logging.ILogger <BeatModsClient> logger) { this._client = clientFactory.GetClient(new Uri("https://beatmods.com/api/v1/")); _cache = cache; _logger = logger; _versionProvider = versionProvider; this.options = options; if (_cache != null) { Task.Run(() => this.CacheLatestGameVersion()).Wait(); } }
public AccountController(Microsoft.Extensions.Logging.ILogger <AccountController> logger, SignInManager <PKUser> signInManager) { _logger = logger; _signInManager = signInManager; }
public ConsoleLogger(Microsoft.Extensions.Logging.ILogger <T> logger) { Logger = logger; }
public ValueProxyService(Microsoft.Extensions.Logging.ILogger <ValueProxyService> @logger, System.Net.Http.HttpClient @client) : base(@logger, @client) { }
public LedgerLocalDbFullDomainUnitOfWorkBase(ILogger <LedgerLocalDbFullDomainUnitOfWorkBase> logger, IDatabaseFactory <LedgerLocalDbContext> databaseFactory) : base(databaseFactory) { _logger = logger; }
public LoggerAdapter(ILoggerFactory loggerFactory) { _logger = loggerFactory.CreateLogger <T>(); }
public NuGetLoggerAdapter(Microsoft.Extensions.Logging.ILogger <T> logger) { this.logger = logger ?? throw new ArgumentNullException("logger"); }
public Logger(Microsoft.Extensions.Logging.ILogger <T> logger) { _logger = logger; }
public Startup(IConfiguration configuration, IWebHostEnvironment environment, Microsoft.Extensions.Logging.ILogger <Startup> logger) { this.configuration = configuration; this.environment = environment; this.logger = logger; NLog.LogManager.LoadConfiguration(System.String.Concat(Directory.GetCurrentDirectory(), "/nlog.config")); Configuration = this.configuration; }