Beispiel #1
0
        private void ConfigureLogging(IServiceCollection services)
        {
            services.AddLykkeLogging();

            var serilogConfigurator = new SerilogConfigurator();

#if DEBUG
            var configBuilder = new ConfigurationBuilder();
            configBuilder.AddJsonFile("serilogsettings.json", optional: false);
            serilogConfigurator.AddFromConfiguration(configBuilder.Build());
#else
            if (!string.IsNullOrWhiteSpace(_appSettings.Db.ConnectionString))
            {
                serilogConfigurator.AddAzureTable(
                    _appSettings.Db.ConnectionString,
                    "SettingsServiceLog");
            }

            if (!string.IsNullOrWhiteSpace(_appSettings.SlackNotificationsConnString) &&
                !string.IsNullOrWhiteSpace(_appSettings.SlackNotificationsQueueName))
            {
                serilogConfigurator.AddAzureQueue(
                    _appSettings.SlackNotificationsConnString,
                    _appSettings.SlackNotificationsQueueName);
            }
#endif
            serilogConfigurator.Configure();
        }
 public static IHostBuilder UseDefaultNetDaemonLogging(this IHostBuilder hostBuilder)
 {
     return(hostBuilder
            .ConfigureWebHostDefaults(webbuilder =>
     {
         Log.Logger = SerilogConfigurator.Configure().CreateLogger();
         webbuilder.UseSerilog(Log.Logger);
     }));
 }
Beispiel #3
0
        public void UsingCode()
        {
            var sink = new MySink();

            Log.Logger = new LoggerConfiguration()
                         .WriteTo.Sink(sink)
                         .CreateLogger();
            SerilogConfigurator.Configure();

            Configure.With()
            .DefaultBuilder();

            Assert.IsNotEmpty(sink.LogEvents);
        }
Beispiel #4
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            SerilogConfigurator.Configure(env);
            loggerFactory.AddSerilog(Log.Logger);
            app.UseCors("default");

            //app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
            //{
            //    Authority = corsSettings.authorityUrl,
            //    RequireHttpsMetadata = false,
            //    ApiName = "LeasingWebApi"
            //});

            app.UseMvc();

            // Enable middleware to serve generated Swagger as a JSON endpoint
            app.UseSwagger();

            // Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.)
            app.UseSwaggerUi(c =>
                             c.SwaggerEndpoint("/swagger/v1/swagger.json", "Demo WebApi")
                             );
        }
Beispiel #5
0
 public static IHostBuilder UseDefaultNetDaemonLogging(this IHostBuilder hostBuilder)
 {
     return(hostBuilder.UseSerilog((context, loggerConfiguration) => SerilogConfigurator.Configure(loggerConfiguration, context.HostingEnvironment)));
 }