public async Task MainAsync(string[] args) { LogManager.LoadConfiguration("nlog.config"); ILoggerFactory loggerFactory = new NLogLoggerFactory(); var logger = loggerFactory.CreateLogger <Program>(); try { var configuration = CreateConfigurationObject(); var clinicalDocumentAPIConfig = new ClinicalDocumentAPIConfig(); configuration.Bind(clinicalDocumentAPIConfig); var options = Options.Create(clinicalDocumentAPIConfig); _restClinicalDocumentAPI = new RestClinicalDocumentAPI(options, loggerFactory); _documentDetailRequest = CreateDocumentDetailRequest(); //POST endpoint of clinical document - Save Clinical Documents var saveClinicalDocumentsResult = await _restClinicalDocumentAPI.SaveClinicalDocumentDetails(_documentDetailRequest); //GET endpoint of clinical document - Get Clinical Documents var getClinicalDocumentsResult = await _restClinicalDocumentAPI.GetClinicalDocumentDetails("TEST", "12345"); } catch (Exception ex) { logger.LogError(ex, "Exception at Clinical Document Console application"); Console.WriteLine(ex); } }
static async Task Main(string[] args) { try { var logFactory = new NLogLoggerFactory(); logFactory.ConfigureNLog(Configuration["NLog:Configuration"]); IConfiguration rabbitConf = BuildConfiguration(Configuration["RabbitMQ:Configuration"]); QueueSender queueSender = new QueueSenderBuilder() .Logger(logFactory.CreateLogger <QueueSender>()) .HostName(rabbitConf["HostName"]) .QueueName(rabbitConf["QueueName"]) .Durable(bool.Parse(rabbitConf["Durable"])) .Exclusive(bool.Parse(rabbitConf["Exclusive"])) .AutoDelete(bool.Parse(rabbitConf["AutoDelete"])) .Arguments(null) .Build(); EnglishWikiFilter filter = new EnglishWikiFilter(); using (queueSender) using (ICrawler crawler = new HttpLinksCrawler(filter.AcceptUri, logFactory.CreateLogger <HttpLinksCrawler>())) { crawler.Subscribe(queueSender.SendToQueue, () => queueSender.Dispose()); await crawler.StartCrawling(Configuration["BaseUri"], Configuration["StartUri"]); } } catch (Exception e) { Console.WriteLine($"Exeption: {e.Message}; Trace: {e.StackTrace}"); } }
static async System.Threading.Tasks.Task Main(string[] args) { var config = new ConfigurationBuilder().AddJsonFile("appconfig.json") .AddUserSecrets <Program>() .Build(); LogManager.Configuration = new NLogLoggingConfiguration(config.GetSection("NLog")); ILoggerFactory loggerFactory = new NLogLoggerFactory(); var programLogger = loggerFactory.CreateLogger <Program>(); try { var imagePuller = GetImagePuller(config, loggerFactory); var imagePusher = GetImagePusher(config, loggerFactory); var imageRepository = GetImageRepository(config, loggerFactory); var lewdBoxApp = new LewdBox(imagePuller, imagePusher, imageRepository); var imageCount = int.Parse(config.GetSection("LewdBoxConfig:PicturePerPushCount").Value); await lewdBoxApp.PostNewHotPictureAsync(imageCount); } catch (Exception ex) { programLogger.LogError(ex, string.Empty); } }
private static ILoggerFactory GetNLogLoggerFactory() { LoggingConfiguration loggerConfig = new NLog.Config.LoggingConfiguration(); FileTarget fileTarget = new NLog.Targets.FileTarget() { Name = "logfile", FileName = "log.txt", Layout = "${longdate}|${level:uppercase=true}|${logger}|${event-context:item=EventId}|${message}|${ndc}" }; loggerConfig.AddTarget(fileTarget); loggerConfig.LoggingRules.Add(new NLog.Config.LoggingRule("*", NLog.LogLevel.Info, fileTarget)); //NLogLoggerFactory test = new NLogLoggerFactory(new NLogLoggerProvider(new NLogProviderOptions())); NLogLoggerFactory logLoggerFactory = new NLogLoggerFactory(); NLogProviderOptions op = new NLogProviderOptions { CaptureMessageProperties = true, CaptureMessageTemplates = true, EventIdSeparator = "|", IgnoreEmptyEventId = false, IncludeScopes = true, //ParseMessageTemplates = true //ShutdownOnDispose = true }; NLogLoggerProvider p = new NLogLoggerProvider(op, loggerConfig.LogFactory); logLoggerFactory.AddProvider(p); return(logLoggerFactory); //loggerFactory.AddNLog(new NLog.LogFactory(loggerConfig)); }
public void CanCreateLoggerFromNameWithLoggerFactory() { var loggerFactory = new NLogLoggerFactory(); var logger = loggerFactory.GetLogger("logger name"); Assert.NotNull(logger); Assert.AreEqual("logger name", logger.Name); }
public void CanCreateLoggerFromCurrentClassWithLoggerFactory() { var loggerFactory = new NLogLoggerFactory(); var logger = loggerFactory.GetCurrentInstanceLogger(); Assert.NotNull(logger); Assert.AreEqual(GetType().FullName, logger.Name); }
public AppRegistry() { var loggerFactory = new NLogLoggerFactory(); this.For(typeof(ILoggerFactory)).Use(loggerFactory); this.For(typeof(ILogger <>)).Use(typeof(Logger <>)); this.For <IStartUpTaskRunner>().Use <DataSynchroniserRunner>(); }
public static void Main(string[] args) { var loggerFactory = new NLogLoggerFactory(); var logger = loggerFactory.CreateLogger <Program>(); var instance = new NetFxLib.NetFxType(logger); instance.DoSomething(); }
public MarkitDataSynchroniserRegistry() { var loggerFactory = new NLogLoggerFactory(); this.For(typeof(ILoggerFactory)).Use(loggerFactory); this.For(typeof(ILogger <>)).Use(typeof(Logger <>)); this.For <IMarkitDataSynchroniser>().Use <MarkitDataSynchroniser>(); }
public SurveillanceRegistry() { var loggerFactory = new NLogLoggerFactory(); this.For(typeof(ILoggerFactory)).Use(loggerFactory); this.For(typeof(ILogger <>)).Use(typeof(Logger <>)); this.For <IMediator>().Use <Mediator>(); }
private static void Main(string[] args) { var loggerFactory = new NLogLoggerFactory(); var logger = loggerFactory.CreateLogger <Program>(); var instance = new NetCoreLib11.NetCoreType11(logger); instance.DoSomething(); }
private void InitializeStatics(IContainerRegistry containerRegistry) { NLogLoggerFactory fac = new NLogLoggerFactory(); Log.Initialize(containerRegistry.GetContainer().Resolve <DialogService>(), fac.CreateLogger("ErrorLog"), fac.CreateLogger("InfoLog")); fac.Dispose(); SourceCodeLocator.Initialize(globalCache); }
public void CanCreateLoggerFromTypeWithLoggerFactory() { var loggerFactory = new NLogLoggerFactory(); var logger = loggerFactory.GetLogger(GetType()); Assert.NotNull(logger); Assert.AreEqual(GetType().FullName, logger.Name); }
public DataImportRegistry() { var loggerFactory = new NLogLoggerFactory(); this.For(typeof(ILoggerFactory)).Use(loggerFactory); this.For(typeof(ILogger <>)).Use(typeof(Logger <>)); this.For <IMediator>().Use <Mediator>(); this.For(typeof(IOrderAllocationStream <>)).Use(typeof(OrderAllocationStream <>)); this.For(typeof(IOrderStream <>)).Use(typeof(OrderStream <>)); this.For <IStockExchangeStream>().Use <ExchangeStream>(); this.For(typeof(IUnsubscriberFactory <>)).Use(typeof(UnsubscriberFactory <>)); this.For <IReddeerDirectory>().Use <ReddeerDirectory>(); this.For <IUploadTradeFileProcessor>().Use <UploadTradeFileProcessor>(); this.For <IUploadTradeFileMonitor>().Use <UploadTradeFileMonitor>(); this.For <ISecurityCsvToDtoMapper>().Use <SecurityCsvToDtoMapper>(); this.For <IS3FileUploadMonitoringProcess>().Use <S3FileUploadMonitoringProcess>(); this.For <IAwsQueueClient>().Use <AwsQueueClient>(); this.For <IFileUploadMessageMapper>().Use <FileUploadMessageMapper>(); this.For <IAwsS3Client>().Use <AwsS3Client>(); this.For <IScheduledExecutionMessageBusSerialiser>().Use <ScheduledExecutionMessageBusSerialiser>(); this.For <IScheduleExecutionDtoMapper>().Use <ScheduleExecutionDtoMapper>(); this.For <IOrderFileValidator>().Use <OrderFileValidator>(); this.For <IOrderFileToOrderSerialiser>().Use <OrderFileToOrderSerialiser>(); this.For <IEnrichmentService>().Use <EnrichmentService>(); this.For <IUploadAllocationFileMonitor>().Use <AllocationFileMonitor>(); this.For <IAllocationFileValidator>().Use <AllocationFileValidator>(); this.For <IAllocationFileCsvToOrderAllocationSerialiser>() .Use <AllocationFileCsvToOrderAllocationSerialiser>(); this.For <IAllocationFileProcessor>().Use <AllocationFileProcessor>(); this.For <IUploadCoordinatorMessageSender>().Use <UploadCoordinatorMessageSender>(); this.For <IEmailNotificationMessageSender>().Use <EmailNotificationMessageSender>(); this.For <IMessageBusSerialiser>().Use <MessageBusSerialiser>(); this.For <Contracts.Email.IMessageBusSerialiser>().Use <Contracts.Email.MessageBusSerialiser>(); this.For <IUploadEtlFileMonitor>().Use <UploadEtlFileMonitor>(); this.For <IUploadEtlFileProcessor>().Use <UploadEtlFileProcessor>(); this.For <IEtlFileValidator>().Use <EtlFileValidator>(); this.For <IEtlUploadErrorStore>().Use <EtlUploadErrorStore>(); this.For <IFileScanner>().Use <FileScanner>(); this.For <IFileScannerScheduler>().Use <FileScannerScheduler>(); this.For <IOmsOrderFieldCompression>().Use <OmsOrderFieldCompression>(); this.For <IOmsVersioner>().Use <OmsVersioner>(); this.For <ITickPriceHistoryServiceClientFactory>().Use <TickPriceHistoryServiceClientFactory>(); this.For <ICfiInstrumentTypeMapper>().Use <CfiInstrumentTypeMapper>(); }
public RefinitivDataSynchroniserRegistry() { var loggerFactory = new NLogLoggerFactory(); For(typeof(ILoggerFactory)).Use(loggerFactory); For(typeof(ILogger <>)).Use(typeof(Logger <>)); For <IRefinitivDataSynchroniser>().Use <RefinitivDataSynchroniser>(); this.For <ITickPriceHistoryServiceClientFactory>().Use <TickPriceHistoryServiceClientFactory>(); }
public void GetShouldReturnNamedNLogLogger() { var expected = "somename"; NLogLoggerFactory tested = new NLogLoggerFactory(); ILog log = tested.GetLog(expected); var actual = log.Name; Assert.IsInstanceOfType(log, typeof(ILog)); Assert.IsInstanceOfType(log, typeof(NLog.Logger)); Assert.AreEqual(expected, actual); }
public AppRegistry() { SystemProcessContext.ProcessType = SystemProcessType.SurveillanceService; var loggerFactory = new NLogLoggerFactory(); this.For(typeof(ILoggerFactory)).Use(loggerFactory); this.For(typeof(ILogger <>)).Use(typeof(Logger <>)); this.For <IStartUpTaskRunner>().Use <MediatorBootstrapper>(); this.For <IScriptRunner>().Use <ScriptRunner.ScriptRunner>(); }
/// <summary> /// Initializes a new instance of the <see cref="RuleSchedulerRegistry"/> class. /// </summary> public RuleSchedulerRegistry() { var loggerFactory = new NLogLoggerFactory(); this.For(typeof(ILoggerFactory)).Use(loggerFactory); this.For(typeof(ILogger <>)).Use(typeof(Logger <>)); this.For <IDelayedScheduler>().Use <DelayedScheduler>(); this.For <IDelayedSchedulerScanner>().Use <DelayedSchedulerScanner>(); this.For <IRuleSchedulerMediator>().Use <Mediator>(); this.For <IQueueScheduledRulePublisher>().Use <QueueScheduledRulePublisher>(); this.For <IQueueDelayedRuleDistributedPublisher>().Use <QueueDelayedRuleDistributedPublisher>(); }
public FactsetDataSynchroniserRegistry() { var loggerFactory = new NLogLoggerFactory(); this.For(typeof(ILoggerFactory)).Use(loggerFactory); this.For(typeof(ILogger <>)).Use(typeof(Logger <>)); this.For <IFactsetDataSynchroniser>().Use <FactsetDataSynchroniser>(); this.For <IFactsetDataRequestFilter>().Use <FactsetDataRequestFilter>(); this.For <IFactsetDataRequestsManager>().Use <FactsetDataRequestsManager>(); this.For <IFactsetDataRequestsApiManager>().Use <FactsetDataRequestsApiManager>(); }
public void Dispose_HappyPath_FlushLogFactory() { // Arrange ConfigureLoggerProvider(); ConfigureNLog(new Targets.Wrappers.BufferingTargetWrapper("buffer", new Targets.MemoryTarget("output"))); var loggerFactory = new NLogLoggerFactory(LoggerProvider); // Act loggerFactory.CreateLogger("test").LogInformation("Hello"); loggerFactory.Dispose(); // Assert Assert.Single(LoggerProvider.LogFactory.Configuration.FindTargetByName <Targets.MemoryTarget>("output").Logs); }
public void CreateLogger_HappyPath_LoggerWithCorrectName() { // Arrange var loggerFactory = new NLogLoggerFactory(); string loggerName = "namespace.class1"; // Act var result = loggerFactory.CreateLogger(loggerName); // Assert Assert.NotNull(result); var logger = Assert.IsType <NLogLogger>(result); Assert.Equal(loggerName, logger.LoggerName); }
public void CreateLogger_SameName_ReturnsSameInstanceTest() { // Arrange var loggerFactory = new NLogLoggerFactory(); string loggerName = "namespace.class1"; // Act var result1 = loggerFactory.CreateLogger(loggerName); var result2 = loggerFactory.CreateLogger(loggerName); // Assert Assert.NotNull(result1); Assert.Equal(loggerName, result1.ToString()); Assert.Same(result1, result2); }
/// <summary> /// Initializes a new instance of the <see cref="DataCoordinatorRegistry"/> class. /// </summary> public DataCoordinatorRegistry() { var loggerFactory = new NLogLoggerFactory(); this.For(typeof(ILoggerFactory)).Use(loggerFactory); this.For(typeof(ILogger <>)).Use(typeof(Logger <>)); this.For <ICoordinatorMediator>().Use <Mediator>(); this.For <IQueueSubscriber>().Use <QueueAutoScheduleSubscriber>(); this.For <IQueueScheduleRulePublisher>().Use <QueueScheduleRulePublisher>(); this.For <IAutoSchedule>().Use <AutoSchedule>(); this.For <IDataVerifier>().Use <DataVerifier>(); this.For <IDataCoordinatorScheduler>().Use <DataCoordinatorScheduler>(); this.For <IActiveRulesService>().Use <ActiveRulesService>(); }
public void Dispose_HappyPath_FlushLogFactory() { // Arrange var loggerFactory = new NLogLoggerFactory(); var internalLogWriter = CaptureInternalLog(); // Act loggerFactory.Dispose(); // Assert var internalLog = internalLogWriter.ToString(); Assert.Contains("LogFactory.Flush", internalLog, StringComparison.OrdinalIgnoreCase); }
/// <summary> /// Initializes a new instance of the <see cref="RuleDistributorRegistry"/> class. /// </summary> public RuleDistributorRegistry() { var loggerFactory = new NLogLoggerFactory(); this.For(typeof(ILoggerFactory)).Use(loggerFactory); this.For(typeof(ILogger <>)).Use(typeof(Logger <>)); this.For <IRuleDistributorMediator>().Use <Mediator>(); this.For <IQueueDistributedRuleSubscriber>().Use <QueueDistributedRuleSubscriber>(); this.For <IScheduledExecutionMessageBusSerialiser>().Use <ScheduledExecutionMessageBusSerialiser>(); this.For <IScheduleExecutionDtoMapper>().Use <ScheduleExecutionDtoMapper>(); this.For <IScheduleDisassembler>().Use <ScheduleDisassembler>(); this.For <IQueueDistributedRulePublisher>().Use <QueueDistributedRulePublisher>(); }
public void AddProvider_StateUnderTest_ExpectedBehavior() { // Arrange var unitUnderTest = new NLogLoggerFactory(); ILoggerProvider provider = new NLogLoggerProvider(); var internalLogWriter = CaptureInternalLog(); // Act unitUnderTest.AddProvider(provider); // Assert var internalLog = internalLogWriter.ToString(); Assert.Contains("AddProvider will be ignored", internalLog, StringComparison.OrdinalIgnoreCase); }
public void Test() { NLog.Config.SimpleConfigurator.ConfigureForConsoleLogging(LogLevel.Trace); var loggerFactory = new NLogLoggerFactory(); var log = loggerFactory.GetLogger("Test"); Assert.IsInstanceOf<NLogLogger>(log); CallAllMethodsOnLog(log); log = loggerFactory.GetLogger(typeof(LoggerFactoryTests)); CallAllMethodsOnLog(log); }
public void Test() { NLog.Config.SimpleConfigurator.ConfigureForConsoleLogging(LogLevel.Trace); var loggerFactory = new NLogLoggerFactory(); var log = loggerFactory.GetLogger("Test"); Assert.IsInstanceOf <NLogLogger>(log); CallAllMethodsOnLog(log); log = loggerFactory.GetLogger(typeof(LoggerFactoryTests)); CallAllMethodsOnLog(log); }
static async Task Main() { Console.Title = "Samples.Logging.ExtensionsLogging"; #region NLogConfiguragion var config = new LoggingConfiguration(); var consoleTarget = new ColoredConsoleTarget { Layout = "${level}|${logger}|${message}${onexception:${newline}${exception:format=tostring}}" }; config.AddTarget("console", consoleTarget); config.LoggingRules.Add(new LoggingRule("*", NLog.LogLevel.Debug, consoleTarget)); NLog.LogManager.Configuration = config; #endregion #region MicrosoftExtensionsLoggingNLog Microsoft.Extensions.Logging.ILoggerFactory extensionsLoggerFactory = new NLogLoggerFactory(); NServiceBus.Logging.ILoggerFactory nservicebusLoggerFactory = new ExtensionsLoggerFactory(loggerFactory: extensionsLoggerFactory); NServiceBus.Logging.LogManager.UseFactory(loggerFactory: nservicebusLoggerFactory); #endregion var endpointConfiguration = new EndpointConfiguration("Samples.Logging.ExtensionsLogging"); endpointConfiguration.UsePersistence <LearningPersistence>(); endpointConfiguration.UseTransport <LearningTransport>(); var endpointInstance = await Endpoint.Start(endpointConfiguration) .ConfigureAwait(false); var myMessage = new MyMessage(); await endpointInstance.SendLocal(myMessage) .ConfigureAwait(false); Console.WriteLine("Press any key to exit"); Console.ReadKey(); await endpointInstance.Stop() .ConfigureAwait(false); }
protected SandboxTestFixture(PlatformType platformType) { var logFactory = new NLogLoggerFactory(); _log = logFactory.CreateLogger(typeof(SandboxTestFixture)); switch (platformType) { case PlatformType.Previous: PreviousApi = CheckoutSdk.Builder() .Previous() .StaticKeys() .PublicKey(System.Environment.GetEnvironmentVariable("CHECKOUT_PREVIOUS_PUBLIC_KEY")) .SecretKey(System.Environment.GetEnvironmentVariable("CHECKOUT_PREVIOUS_SECRET_KEY")) .Environment(Environment.Sandbox) .LogProvider(logFactory) .HttpClientFactory(new DefaultHttpClientFactory()) .Build(); break; case PlatformType.Default: DefaultApi = CheckoutSdk.Builder().StaticKeys() .PublicKey(System.Environment.GetEnvironmentVariable("CHECKOUT_DEFAULT_PUBLIC_KEY")) .SecretKey(System.Environment.GetEnvironmentVariable("CHECKOUT_DEFAULT_SECRET_KEY")) .Environment(Environment.Sandbox) .LogProvider(logFactory) .Build(); break; case PlatformType.DefaultOAuth: DefaultApi = CheckoutSdk.Builder().OAuth() .ClientCredentials(System.Environment.GetEnvironmentVariable("CHECKOUT_DEFAULT_OAUTH_CLIENT_ID"), System.Environment.GetEnvironmentVariable("CHECKOUT_DEFAULT_OAUTH_CLIENT_SECRET")) .Scopes(OAuthScope.Files, OAuthScope.Flow, OAuthScope.Fx, OAuthScope.Gateway, OAuthScope.Marketplace, OAuthScope.SessionsApp, OAuthScope.SessionsBrowser, OAuthScope.Vault, OAuthScope.PayoutsBankDetails, OAuthScope.TransfersCreate, OAuthScope.TransfersView, OAuthScope.BalancesView) .Environment(Environment.Sandbox) .LogProvider(logFactory) .Build(); break; default: throw new ArgumentOutOfRangeException(nameof(platformType), platformType, null); } }
public BmllDataSynchroniserRegistry() { var loggerFactory = new NLogLoggerFactory(); this.For(typeof(ILoggerFactory)).Use(loggerFactory); this.For(typeof(ILogger <>)).Use(typeof(Logger <>)); this.For <IBmllDataSynchroniser>().Use <BmllDataSynchroniser>(); this.For <IBmllDataRequestFilter>().Use <BmllDataRequestFilter>(); this.For <IBmllDataRequestManager>().Use <BmllDataRequestsManager>(); this.For <IBmllDataRequestsApiManager>().Use <BmllDataRequestsApiManager>(); this.For <IBmllDataRequestsStorageManager>().Use <BmllDataRequestsStorageManager>(); this.For <IGetTimeBarPair>().Use <GetTimeBarPair>(); this.For <IMarketDataRequestToMinuteBarRequestKeyDtoProjector>() .Use <MarketDataRequestToMinuteBarRequestKeyDtoProjector>(); this.For <IBmllDataRequestsGetTimeBars>().Use <BmllDataRequestsGetTimeBars>(); this.For <IPolicyFactory>().Use <PolicyFactory>(); }