Ejemplo n.º 1
1
 public SerilogLogger()
 {
     // read configuration
     log = new LoggerConfiguration()
         .ReadFrom.AppSettings()
         .CreateLogger();
 }
Ejemplo n.º 2
1
 public SerilogLogger(Serilog.ILogger logger)
 {
     log = logger;
 }
Ejemplo n.º 3
0
    public LogBenchmark()
    {
        // Microsoft Logger
        _msLogger = LoggerFactory.Create(builder => builder
                                         .SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Warning)
                                         .AddConsole())
                    .CreateLogger <LogBenchmark>();

        // NLog
        _nLogger = LogManager.Setup().SetupInternalLogger(builder =>
                                                          builder.SetMinimumLogLevel(NLog.LogLevel.Warn)
                                                          .LogToConsole(true))
                   .GetCurrentClassLogger();

        // Serilog
        _sLogger = new Serilog.LoggerConfiguration()
                   .MinimumLevel.Warning()
                   .WriteTo.Console()
                   .CreateLogger();

        // Microsoft LoggerMessage.Define
        _myHelloLog = LoggerMessage.Define <int>(Microsoft.Extensions.Logging.LogLevel.Information,
                                                 new EventId(2, nameof(LogBenchmark)),
                                                 Message);
    }
Ejemplo n.º 4
0
 private Logger()
 {
     _serilogger = new LoggerConfiguration()
                   //.Enrich.WithThreadId()
                   .WriteTo.Seq("http://localhost:5341")
                   .CreateLogger();
 }
Ejemplo n.º 5
0
        public DapperORM(IDbConnection conn, object model)
        {
            this.connection = conn;

            var    t         = model.GetType();
            string tableName = this.GetTableName(t).ToUpper();
            string synonym   = this.GetTableSynonym(t).ToUpper();

            this.GetColumnList(tableName);


            if (synonym == "")
            {
                this.TableName = tableName;
            }
            else
            {
                this.TableName = synonym + "." + tableName;
            }


            this.Model = model;

            this.logger = Log.Logger;;
        }
Ejemplo n.º 6
0
 public OwinLoggerFactory(ILogger logger = null, Func<TraceEventType, LogEventLevel> getLogEventLevel = null)
 {
     _loggerFactory = logger == null
         ? (Func<ILogger>)(() => Log.Logger)
         : (() => logger);
     _mapLogLevel = getLogEventLevel ?? ToLogEventLevel;
 }
Ejemplo n.º 7
0
    private static ServiceProvider SetupDi(ConfigInfo configInfo, Serilog.ILogger logger)
    {
        var services = new ServiceCollection()
                       .AddLogging()
                       .AddSingleton <ILoggerFactory>(services => new SerilogLoggerFactory(logger, false))
                       .AddSingleton(configInfo)
                       .AddScoped(sp => HttpClientBuilder())
                       .AddScoped <HttpService>()
                       .AddScoped <GetAllVideosService>()
                       .AddScoped <GetAnimatedThumbnailService>()
                       .AddScoped <GetAllAnimatedThumbnailService>()
                       .AddScoped <GetStatusAnimatedThumbnailService>()
                       .AddScoped <AddAnimatedThumbnailsToVideoService>()
                       .AddScoped <AddDomainToVideoService>()
                       .AddScoped <CompleteUploadByCompleteUriService>()
                       .AddScoped <GetStreamingTicketService>()
                       .AddScoped <UpdateVideoDetailsService>()
                       .AddScoped <UploadVideoService>()
                       .AddScoped <DeleteVideoService>()
                       .AddScoped <GetVideoService>()
                       .AddScoped <UploaderService>()
                       .AddScoped <ActiveTextTrackService>()
                       .AddScoped <GetUploadLinkTextTrackService>()
                       .AddScoped <UploadTextTrackFileService>()
                       .AddScoped <UploadSubtitleToVideoService>()
                       .AddScoped <GetAllTextTracksService>();

        return(services.BuildServiceProvider());
    }
Ejemplo n.º 8
0
 public NationStatsCommand(IServiceProvider serviceProvider)
 {
     _logger          = Log.ForContext <NationStatsCommand>();
     _dispatcher      = serviceProvider.GetRequiredService <IRequestDispatcher>();
     _config          = serviceProvider.GetRequiredService <IOptions <AppSettings> >().Value;
     _responseBuilder = serviceProvider.GetRequiredService <IResponseBuilder>();
 }
 public ConsumerBackgroundService(Serilog.ILogger logger, CategorysService categoryService,
                                  SpecificationsService specificationService,
                                  SpecificationsGroupService specificationGroupService,
                                  BrandsService brandsService,
                                  ProductsService productService,
                                  SKUService SKUService,
                                  SpecificationValuesService specificationValuesService,
                                  ProductSpecificationsService productSpecificationsService,
                                  SKUSpecificationsService SKUSpecificationsService,
                                  SKUFilesService SKUFilesService,
                                  InventoryService inventoryService,
                                  PricesService pricesService,
                                  MotosService motosService,
                                  FeedService feedService,
                                  OrderService ordersService)
 {
     _logger                       = logger;
     _categoryService              = categoryService;
     _specificationService         = specificationService;
     _specificationGroupService    = specificationGroupService;
     _brandsService                = brandsService;
     _productService               = productService;
     _SKUService                   = SKUService;
     _specificationValuesService   = specificationValuesService;
     _productSpecificationsService = productSpecificationsService;
     _SKUSpecificationsService     = SKUSpecificationsService;
     _SKUFilesService              = SKUFilesService;
     _inventoryService             = inventoryService;
     _pricesService                = pricesService;
     _motosService                 = motosService;
     _feedService                  = feedService;
     _ordersService                = ordersService;
 }
Ejemplo n.º 10
0
        // TODO Flush / close when exiting
        static GlobalLogging()
        {
            DiagnosticStopWatch = new Stopwatch();

            var userProfile   = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
            var ownVersion    = typeof(GlobalLogging).Assembly.GetName().Version;
            var dynamoVersion = typeof(IsVisibleInDynamoLibraryAttribute).Assembly.GetName().Version;

            log = new LoggerConfiguration()
                  .MinimumLevel.ControlledBy(new LoggingLevelSwitch(Serilog.Events.LogEventLevel.Debug))

                  /*.WriteTo.Async(a => a.File(
                   *  $"{userProfile}\\TRexIfc-{ownVersion.Major}.{ownVersion.Minor}_Dynamo-{dynamoVersion.Major}.{dynamoVersion.Minor}_.log",
                   *  rollingInterval: RollingInterval.Day,
                   *  rollOnFileSizeLimit: true,
                   *  outputTemplate: messageTemplate), bufferSize: 500)*/
                  .WriteTo.File(
                $"{userProfile}\\TRexIfc-{ownVersion.Major}.{ownVersion.Minor}_Dynamo-{dynamoVersion.Major}.{dynamoVersion.Minor}_.log",
                buffered: false,
                rollingInterval: RollingInterval.Day,
                rollOnFileSizeLimit: true,
                outputTemplate: messageTemplate)
                  .Enrich.WithThreadId()
                  .Enrich.WithThreadName()
                  .Enrich.FromLogContext()
                  .CreateLogger();

            loggingFactory     = new LoggerFactory().AddSerilog(log, true);
            Serilog.Log.Logger = log;

            log.Information($"Started TRexIfc-{ownVersion} on Dynamo-{dynamoVersion} host at {DateTime.Now}.");
        }
Ejemplo n.º 11
0
 public OwinLoggerFactory(ILogger logger = null, Func <TraceEventType, LogEventLevel> getLogEventLevel = null)
 {
     _loggerFactory = logger == null
         ? (Func <ILogger>)(() => Log.Logger)
         : (() => logger);
     _mapLogLevel = getLogEventLevel ?? ToLogEventLevel;
 }
Ejemplo n.º 12
0
        public static int Main(string[] args)
        {
            var configuration = GetConfiguration();

            Serilog.ILogger log = CreateSerilogLogger(configuration);
            Log.Logger = log;

            try
            {
                Log.Information("Configuring web host ({ApplicationContext})...", AppName);
                host = BuildWebHost(configuration, log, args);


                Log.Information("Starting web host ({ApplicationContext})...", AppName);
                host.Run();

                return(0);
            }
            catch (Exception ex)
            {
                Log.Fatal(ex, "Program terminated unexpectedly ({ApplicationContext})!", AppName);
                return(1);
            }
            finally
            {
                Log.CloseAndFlush();
            }
        }
Ejemplo n.º 13
0
 public OdissLogger(IPrincipalService principalService)
 {
     this.principalService = principalService;
     this.serilogLogger    = new LoggerConfiguration()
                             .ReadFrom.AppSettings()
                             .CreateLogger();
 }
        public static IHostBuilder UseSerilog(
            this IHostBuilder builder,
            Action <HostBuilderContext, LoggerConfiguration> configureLogger,
            bool preserveStaticLogger = false,
            bool writeToProviders     = false)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (configureLogger == null)
            {
                throw new ArgumentNullException(nameof(configureLogger));
            }

            builder.ConfigureServices((context, collection) =>
            {
                var loggerConfiguration = new LoggerConfiguration();

                LoggerProviderCollection loggerProviders = null;
                if (writeToProviders)
                {
                    loggerProviders = new LoggerProviderCollection();
                    loggerConfiguration.WriteTo.Providers(loggerProviders);
                }

                configureLogger(context, loggerConfiguration);
                var logger = loggerConfiguration.CreateLogger();

                Serilog.ILogger registeredLogger = null;
                if (preserveStaticLogger)
                {
                    registeredLogger = logger;
                }
                else
                {
                    // Passing a `null` logger to `SerilogLoggerFactory` results in disposal via
                    // `Log.CloseAndFlush()`, which additionally replaces the static logger with a no-op.
                    Log.Logger = logger;
                }

                collection.AddSingleton <ILoggerFactory>(services =>
                {
                    var factory = new SerilogLoggerFactory(registeredLogger, true, loggerProviders);

                    if (writeToProviders)
                    {
                        foreach (var provider in services.GetServices <ILoggerProvider>())
                        {
                            factory.AddProvider(provider);
                        }
                    }

                    return(factory);
                });

                ConfigureServices(collection, logger);
            });
            return(builder);
        }
Ejemplo n.º 15
0
 public static IHostBuilder UseSerilog(this IHostBuilder builder,
                                       Serilog.ILogger logger = null, IConfiguration configuration = null, bool dispose = false)
 {
     builder.ConfigureServices((context, collection) =>
                               collection.Configure <IConfiguration>(configuration).AddSingleton <ILoggerFactory>(services => new SerilogLoggerFactory(logger, dispose)));
     return(builder);
 }
 /// <summary>
 /// Siteminder Authentication Constructir
 /// </summary>
 /// <param name="configureOptions"></param>
 /// <param name="loggerFactory"></param>
 /// <param name="encoder"></param>
 /// <param name="clock"></param>
 public SiteminderAuthenticationHandler(IOptionsMonitor <SiteMinderAuthOptions> configureOptions, ILoggerFactory loggerFactory, UrlEncoder encoder, ISystemClock clock)
     : base(configureOptions, loggerFactory, encoder, clock)
 {
     _logger    = Log.Logger;
     _ms_logger = loggerFactory.CreateLogger(typeof(SiteminderAuthenticationHandler));
     _options   = new SiteMinderAuthOptions();
 }
Ejemplo n.º 17
0
 public PizzaCore(BotConfig botConfig, ILogger logger)
 {
     _botConfig   = botConfig ?? throw new ArgumentNullException(nameof(botConfig));
     _logger      = logger ?? throw new ArgumentNullException(nameof(logger));
     Client       = new SlackTaskClient(_botConfig.SlackApiKey);
     SocketClient = new SlackSocketClient(_botConfig.SlackApiKey);
 }
Ejemplo n.º 18
0
        public CockpitViewModel()
        {
            if (IsInDesignMode)
            {
                // Code runs in Blend --> create design time data.
            }
            else
            {
                logger = new LoggerConfiguration()
                         .WriteTo.Logger(Log.Logger)
                         .WriteTo.ObservableCollection(Logs, Dispatcher.CurrentDispatcher)
                         .CreateLogger();

                beatSaver = new BeatSaver(new HttpOptions()
                {
                    ApplicationName  = "TwitchToSpeech",
                    Version          = Assembly.GetExecutingAssembly().GetName().Version,
                    HandleRateLimits = true
                });

                ConnectToTwitchCommand = new RelayCommand(ConnectToTwitch);
                dispatcher             = Dispatcher.CurrentDispatcher;
                taskQueue = new TaskQueue();
                speech    = new SpeechSynthesizer();

                Settings.PropertyChanged += (s, e) => SettingsChanged();
                SettingsChanged();
            }
        }
 static FileLoggingBenchmark()
 {
     serilogLogger = CreateSerilogLogger();
     nlogLogger    = CreateNLogLogger();
     log4NetLogger = CreateLog4NetLogger();
     streamWriter  = CreateStreamWriter();
 }
Ejemplo n.º 20
0
        internal static void BuildLogger(ref Serilog.ILogger _perfLogger, ref Serilog.ILogger _usageLogger, ref Serilog.ILogger _errorLogger, ref Serilog.ILogger _diagnosticLogger, McsLoggingSettings _settings)
        {
            _perfLogger = new LoggerConfiguration()
                          .WriteTo.File(path: $"{_settings.LogFolderLocation}\\perf-{DateTime.Now.ToString("MMddyyyy")}.txt")
                          .WriteTo.MSSqlServer(_settings.LogConnection, "PerfLogs", autoCreateSqlTable: true,
                                               columnOptions: SqlColumns.GetSqlColumnOptions(), batchPostingLimit: _settings.LogBatchSize)
                          .CreateLogger();

            _usageLogger = new LoggerConfiguration()
                           .WriteTo.File(path: $"{_settings.LogFolderLocation}\\usage-{DateTime.Now.ToString("MMddyyyy")}.txt")
                           .WriteTo.MSSqlServer(_settings.LogConnection, "UsageLogs", autoCreateSqlTable: true,
                                                columnOptions: SqlColumns.GetSqlColumnOptions(), batchPostingLimit: _settings.LogBatchSize)
                           .CreateLogger();

            _errorLogger = new LoggerConfiguration()
                           .WriteTo.File(path: $"{_settings.LogFolderLocation}\\error-{DateTime.Now.ToString("MMddyyyy")}.txt")
                           .WriteTo.MSSqlServer(_settings.LogConnection, "ErrorLogs", autoCreateSqlTable: true,
                                                columnOptions: SqlColumns.GetSqlColumnOptions(), batchPostingLimit: _settings.LogBatchSize)
                           .CreateLogger();

            _diagnosticLogger = new LoggerConfiguration()
                                .WriteTo.File(path: $"{_settings.LogFolderLocation}\\diagnostic-{DateTime.Now.ToString("MMddyyyy")}.txt")
                                .WriteTo.MSSqlServer(_settings.LogConnection, "DiagnosticLogs", autoCreateSqlTable: true,
                                                     columnOptions: SqlColumns.GetSqlColumnOptions(), batchPostingLimit: _settings.LogBatchSize)
                                .CreateLogger();
        }
 public MainWindowViewModel(IRegionManager regionManager, Serilog.ILogger logger)
 {
     this._regionManager    = regionManager;
     this.LoadModuleCommand = new PrismCommands.DelegateCommand <string>(this.LoadModuleHandler);
     this.LoadedCommand     = new Prism.Commands.DelegateCommand(this.LoadedHandler);
     this._logger           = logger;
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Creates the LoggerFactory implementing ILoggerfactory of Microsoft.Extensions.Loggins
        /// </summary>
        /// <returns></returns>
        private static ILoggerFactory CreateLoggerFactory(Serilog.ILogger logger)
        {
            ILoggerFactory loggerFactory = new LoggerFactory();

            loggerFactory.AddSerilog(logger);
            return(loggerFactory);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Creates the WebHostBuilder.
        /// </summary>
        /// <param name="args">the arguments</param>
        /// <returns></returns>
        public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
        .ConfigureWebHostDefaults(webBuilder =>
        {
            webBuilder.UseStartup <Startup>().UseUrls("http://*:5010");
        })
        .ConfigureAppConfiguration((hostingContext, config) =>
        {
            LoadAppSettingsFiles(config);

            ConnectToKeyVaultAndSetApplicationInsigths(config);

            config.AddEnvironmentVariables();
            config.AddCommandLine(args);
        })
        .ConfigureLogging((hostingContext, logging) =>
        {
            logging.ClearProviders();
            LoggerConfiguration loggerConfig = new LoggerConfiguration().WriteTo.Console().MinimumLevel.Warning();

            if (!string.IsNullOrEmpty(Startup.ApplicationInsightsKey))
            {
                loggerConfig.WriteTo.ApplicationInsights(new TelemetryConfiguration(Startup.ApplicationInsightsKey), TelemetryConverter.Traces);
            }

            Serilog.ILogger logger = loggerConfig.CreateLogger();

            logging.AddProvider(new SerilogLoggerProvider(logger));
        });
Ejemplo n.º 24
0
 public ReciboController(RecibosRepository repository, Serilog.ILogger logger, IMapper mapper, IWebHostEnvironment env)
 {
     Repository = repository;
     Logger     = logger;
     Mapper     = mapper;
     Env        = env;
 }
Ejemplo n.º 25
0
        /// <summary>
        /// Configure the configuration builder
        /// </summary>
        /// <param name="args">arguments for creating build configuration</param>
        /// <returns>The web host builder</returns>
        public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
        .ConfigureWebHostDefaults(webBuilder =>
        {
            webBuilder.ConfigureAppConfiguration((hostingContext, config) =>
            {
                _logger.Information($"Program // ConfigureAppConfiguration");

                string basePath = Directory.GetParent(Directory.GetCurrentDirectory()).FullName;

                string basePathCurrentDirectory = Directory.GetCurrentDirectory();
                _logger.Information($"Current directory is: {basePathCurrentDirectory}");

                LoadConfigurationSettings(config, basePath, args);
            })

            .UseStartup <Startup>();
        })
        .ConfigureLogging((hostingContext, logging) =>
        {
            logging.ClearProviders();
            LoggerConfiguration loggerConfig = new LoggerConfiguration().WriteTo.Console();

            if (!string.IsNullOrEmpty(Startup.ApplicationInsightsKey))
            {
                loggerConfig.WriteTo.ApplicationInsights(new TelemetryConfiguration(Startup.ApplicationInsightsKey), TelemetryConverter.Traces);
            }

            Serilog.ILogger logger = loggerConfig.CreateLogger();

            logging.AddProvider(new SerilogLoggerProvider(logger));
        })
        ;
Ejemplo n.º 26
0
        public Logger()
        {
            var version     = ConfigurationManager.AppSettings["Version"];
            var environment = ConfigurationManager.AppSettings["Environment"];
            var elasticsearchEndpointValue = ConfigurationManager.AppSettings["ElasticsearchEndpoint"];

            try
            {
                _log = new LoggerConfiguration()
                       .Enrich.WithProperty("Version", version)
                       .Enrich.WithProperty("Environment", environment)
                       .Enrich.WithProperty("Application", "FoosballApi")

                       /*.WriteTo.Elasticsearch(
                        *      new ElasticsearchSinkOptions(new Uri(elasticsearchEndpointValue))
                        *      {
                        *          AutoRegisterTemplate = true,
                        *          BufferBaseFilename = @"c:\temp\logs\elasticsearchbuffer"
                        *      })*/
                       .WriteTo.LogReceiver()
                       .MinimumLevel.Debug()
                       .CreateLogger();
            }
            catch (Exception)
            {
                //ignore
            }
        }
        /// <summary>
        /// Initializes a new instance of Advanced logger
        /// </summary>
        /// <param name="enableSerilogRequestResponseLoggingForDebug"></param>
        /// <param name="enableSerilogRequestResponseLoggingForTrace"></param>
        /// <param name="enableSerilogRequestResponseLoggingForConsole"></param>
        /// <param name="enableSerilogRequestResponseLoggingForFile"></param>
        /// <param name="serviceRequestLoggingLocationForFile"></param>
        public OAuthAdvancedLogging(bool enableSerilogRequestResponseLoggingForDebug, bool enableSerilogRequestResponseLoggingForTrace, bool enableSerilogRequestResponseLoggingForConsole, bool enableSerilogRequestResponseLoggingForFile, string serviceRequestLoggingLocationForFile)
        {
            this.EnableSerilogRequestResponseLoggingForDebug   = enableSerilogRequestResponseLoggingForDebug;
            this.EnableSerilogRequestResponseLoggingForTrace   = enableSerilogRequestResponseLoggingForTrace;
            this.EnableSerilogRequestResponseLoggingForConsole = enableSerilogRequestResponseLoggingForConsole;
            this.EnableSerilogRequestResponseLoggingForFile    = enableSerilogRequestResponseLoggingForFile;
            this.ServiceRequestLoggingLocationForFile          = serviceRequestLoggingLocationForFile;



            string filePath = string.Empty;

            if (this.EnableSerilogRequestResponseLoggingForFile)
            {
                //Assign tempath if no location found
                if (string.IsNullOrWhiteSpace(this.ServiceRequestLoggingLocationForFile))
                {
                    this.ServiceRequestLoggingLocationForFile = Path.GetTempPath();
                }


                //Log file path for widows n ios
                filePath = Path.Combine(this.ServiceRequestLoggingLocationForFile, "QBOApiLogs-" + DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture) + ".txt");
            }

            //Setting logger config for Serilog
            var loggerConfig = new LoggerConfiguration()
                               .MinimumLevel.Verbose();


            //Enabling console log
            if (this.EnableSerilogRequestResponseLoggingForConsole == true)
            {
                loggerConfig = loggerConfig.WriteTo.Console();
            }

            //Enabling Trace log
            if (this.EnableSerilogRequestResponseLoggingForTrace == true)
            {
                loggerConfig = loggerConfig.WriteTo.Trace();
            }

            //Enabling Debug log
            if (this.EnableSerilogRequestResponseLoggingForDebug == true)
            {
                loggerConfig = loggerConfig.WriteTo.Debug();
            }

            //Enabling file log
            if (!string.IsNullOrEmpty(this.ServiceRequestLoggingLocationForFile) && this.EnableSerilogRequestResponseLoggingForFile == true)
            {
                loggerConfig = loggerConfig.WriteTo.File(filePath);
            }

            //Creating the Logger for Serilog
            logger = loggerConfig.CreateLogger();

            //Logging first info
            logger.Information("Logger is initialized");
        }
Ejemplo n.º 28
0
        public Logger()
        {
            var version = ConfigurationManager.AppSettings["Version"];
            var environment = ConfigurationManager.AppSettings["Environment"];
            var elasticsearchEndpointValue = ConfigurationManager.AppSettings["ElasticsearchEndpoint"];

            try
            {
                _log = new LoggerConfiguration()
                        .Enrich.WithProperty("Version",version)
                        .Enrich.WithProperty("Environment",environment)
                        .Enrich.WithProperty("Application","FoosballApi")
                        /*.WriteTo.Elasticsearch(
                                new ElasticsearchSinkOptions(new Uri(elasticsearchEndpointValue))
                                {
                                    AutoRegisterTemplate = true,
                                    BufferBaseFilename = @"c:\temp\logs\elasticsearchbuffer"
                                })*/
                        .WriteTo.LogReceiver()
                        .MinimumLevel.Debug()
                        .CreateLogger();
            }
            catch (Exception)
            {
                //ignore
            }
        }
Ejemplo n.º 29
0
        private static void ConfigureCompositionRoot(
            string connectionString,
            IExecutionContextAccessor executionContextAccessor,
            ILogger logger)
        {
            var containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterModule(new LoggingModule(logger));

            var loggerFactory = new SerilogLoggerFactory(logger);

            containerBuilder.RegisterModule(new DataAccessModule(connectionString, loggerFactory));

            containerBuilder.RegisterModule(new ProcessingModule());
            containerBuilder.RegisterModule(new EventsBusModule());
            containerBuilder.RegisterModule(new MediatorModule());
            containerBuilder.RegisterModule(new AuthenticationModule());
            containerBuilder.RegisterModule(new OutboxModule());
            containerBuilder.RegisterModule(new QuartzModule());

            containerBuilder.RegisterInstance(executionContextAccessor);

            _container = containerBuilder.Build();

            PaymentsCompositionRoot.SetContainer(_container);
        }
Ejemplo n.º 30
0
        public virtual void SetUp()
        {
            logger = new LoggerConfiguration()
                     .MinimumLevel.Information()
                     .WriteTo.NUnitOutput()
                     .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss.ffff } {Level}] {Message:lj}{NewLine}{Exception}")
                     .CreateLogger();

            var loggerFactory = new LoggerFactory(new List <ILoggerProvider> {
                new SerilogLoggerProvider(logger)
            });

            db = CreateDbContext(loggerFactory);

            serviceProvider = ConfigureServices();

            userManager = serviceProvider.GetService <UlearnUserManager>();
            CreateInitialDataInDatabaseAsync().GetAwaiter().GetResult();
            CreateTestUsersAsync().GetAwaiter().GetResult();

            /* Configuring Z.EntityFramework.Plus for working with In-Memory database
             * See https://entityframework-plus.net/batch-delete for details. */
            BatchDeleteManager.InMemoryDbContextFactory = () => CreateDbContext(loggerFactory);

            /* Cache Manager is not working with In-Memory database.
             * See https://github.com/zzzprojects/EntityFramework-Plus/issues/391 for details. */
            QueryCacheManager.IsEnabled = false;
        }
Ejemplo n.º 31
0
 public SerilogLogger()
 {
     // read configuration
     log = new LoggerConfiguration()
           .ReadFrom.AppSettings()
           .CreateLogger();
 }
Ejemplo n.º 32
0
 public GameClient(TcpConnection connection)
 {
     Logger        = Log.ForContext <GameClient>();
     TcpConnection = connection;
     connection.OnPacketReceived   += Connection_OnPacketReceived;
     connection.OnConnectionClosed += Connection_OnConnectionClosed;
 }
        /// <summary>
        /// The UseExceptionHandler middleware is a built-in middleware
        /// </summary>
        /// <param name="app"></param>
        public static void ConfigureExceptionHandler(this IApplicationBuilder app, ILogger seriLogger) //, ILoggerManager logger)
        {
            // built-in middleware
            app.UseExceptionHandler(appError =>
            {
                appError.Run(async context =>
                {
                    context.Response.StatusCode  = (int)HttpStatusCode.InternalServerError;
                    context.Response.ContentType = "application/json";

                    var contextFeature = context.Features.Get <IExceptionHandlerFeature>();
                    if (contextFeature != null)
                    {
                        //LogError($"Something went wrong: {contextFeature.Error}");
                        seriLogger.Information($"Something went wrong: {contextFeature.Error}");

                        await context.Response.WriteAsync(new ErrorDetailModel()
                        {
                            StatusCode = context.Response.StatusCode,
                            Message    = "Middleware says: Internal Server Error. "
                        }.ToString());
                    }
                });
            });
        }
Ejemplo n.º 34
0
 public JwtController(ILoginService loginService, IApiKeyValiationService apikeyValidService, ITokenService tokenService)
 {
     this.loginService       = loginService;
     this.apikeyValidService = apikeyValidService;
     this.tokenService       = tokenService;
     this.logger             = Log.Logger;
 }
Ejemplo n.º 35
0
        public void Before_any_tests()
        {
            _baseLogger = new LoggerConfiguration()
                .MinimumLevel.Debug()
                .WriteTo.Console()
                .CreateLogger();

            SerilogLogger.Use(_baseLogger);
        }
Ejemplo n.º 36
0
        public SerilogLogger()
        {
            _log = new LoggerConfiguration()
                .MinimumLevel.Debug()
                .WriteTo.File("c:\\temp\\log.txt")
                .CreateLogger();

            var isdebug = _log.IsEnabled(LogEventLevel.Debug);
        }
Ejemplo n.º 37
0
 public Logger()
 {
     _log = new LoggerConfiguration()
                 .MinimumLevel.Debug()
     #if DEBUG
                 .WriteTo.ColoredConsole()
     #endif
                 .WriteTo.RollingFile($@"{Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)}\IwAutoUpdaterService\Logs\" + "log_{Date}.txt", retainedFileCountLimit: 10)
     #if (!DEBUG)
                 // unsere EventSource wird schon von TopShelf angelegt (heißt automatisch so wie der Service)
                 .WriteTo.EventLog("IwAutoUpdaterService", "IwAutoUpdaterService", manageEventSource: false, restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Information)
     #endif
                 .CreateLogger();
 }
Ejemplo n.º 38
0
 public Logger(ISerilogLogger logger = null)
 {
     _logger = logger;
 }
Ejemplo n.º 39
0
 /// <summary>
 /// Constructor. Uses default serilog config if not provided.
 /// </summary>
 /// <param name="type">The source object of where the log message originated</param>
 /// <param name="serilogger">The <see cref="ILogger"/> implementation to use. Will fall back to default if not provided (can be null)</param>
 public SerilogLogger(Type type, ILogger serilogger)
 {
     _type = type;
     _logger = serilogger ?? CreateDefaultSerilogger();
 }
Ejemplo n.º 40
0
 public SerilogLogger(SerilogRollingFileConfiguration fileConfiguration)
 {
     _logger =
         CreateDefaultConfiguration(fileConfiguration)
         .CreateLogger();
 }
Ejemplo n.º 41
0
 internal OwinLogger(ILogger logger, Func<TraceEventType, LogEventLevel> getLogEventLevel)
 {
     _logger = logger;
     _getLogEventLevel = getLogEventLevel;
 }
Ejemplo n.º 42
0
 private SerilogLogger(Serilog.ILogger logger)
 {
     _log = logger;
 }
Ejemplo n.º 43
0
 public SerilogLogger(Serilog.ILogger baseLogger = null, bool demoteDebug = false)
 {
     _baseLogger = baseLogger;
     _demoteDebug = demoteDebug;
     _logs = new ConcurrentDictionary<string, ILog>();
 }
Ejemplo n.º 44
0
 public SerilogLogger(ISerilogLogger logger)
 {
     if (logger == null) throw new ArgumentNullException("logger");
     _logger = logger;
 }
Ejemplo n.º 45
0
 public SLogger()
 {
     m_logger = new Serilog.LoggerConfiguration()
          .ReadFrom.AppSettings()
          .CreateLogger();
 }
Ejemplo n.º 46
0
 public Logger()
 {
     _logger = new LoggerConfiguration().WriteTo.NLog().MinimumLevel.Verbose().CreateLogger();
 }