diff --git a/BTCPayServer/Hosting/Startup.cs b/BTCPayServer/Hosting/Startup.cs index dcb995d2e..3f903c750 100644 --- a/BTCPayServer/Hosting/Startup.cs +++ b/BTCPayServer/Hosting/Startup.cs @@ -34,6 +34,7 @@ using Hangfire.Annotations; using Microsoft.Extensions.DependencyInjection.Extensions; using System.Threading; using Microsoft.Extensions.Options; +using Microsoft.ApplicationInsights.AspNetCore.Extensions; namespace BTCPayServer.Hosting { @@ -51,11 +52,12 @@ namespace BTCPayServer.Hosting return context.GetHttpContext().User.IsInRole(_Role); } } - public Startup(IConfiguration conf) + public Startup(IConfiguration conf, IHostingEnvironment env) { Configuration = conf; + _Env = env; } - + IHostingEnvironment _Env; public IConfiguration Configuration { get; set; @@ -99,12 +101,19 @@ namespace BTCPayServer.Hosting } configuration(config); })); + services.AddHangfire(configuration); + + services.Configure>(o => + { + o.Value.DeveloperMode = _Env.IsDevelopment(); + }); } public void Configure( IApplicationBuilder app, IHostingEnvironment env, + IServiceProvider prov, ILoggerFactory loggerFactory) { if(env.IsDevelopment()) @@ -115,6 +124,10 @@ namespace BTCPayServer.Hosting Logs.Configure(loggerFactory); + + //App insight do not that by itself... + loggerFactory.AddApplicationInsights(prov, LogLevel.Information); + app.UsePayServer(); app.UseStaticFiles(); app.UseAuthentication(); diff --git a/BTCPayServer/Program.cs b/BTCPayServer/Program.cs index a93180170..18acaecf3 100644 --- a/BTCPayServer/Program.cs +++ b/BTCPayServer/Program.cs @@ -14,6 +14,7 @@ using System.Net; using System.Collections.Generic; using System.Collections; using Microsoft.AspNetCore.Hosting.Server.Features; +using Microsoft.Extensions.Logging; using System.Threading; namespace BTCPayServer @@ -40,13 +41,11 @@ namespace BTCPayServer .UseIISIntegration() .UseContentRoot(Directory.GetCurrentDirectory()) .UseConfiguration(conf) - .ConfigureServices(services => + .UseApplicationInsights() + .ConfigureLogging(l => { - services.AddLogging(l => - { - l.AddFilter("Microsoft", LogLevel.Error); - l.AddProvider(new CustomConsoleLogProvider()); - }); + l.AddFilter("Microsoft", LogLevel.Error); + l.AddProvider(new CustomConsoleLogProvider()); }) .UseStartup() .Build();