mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-19 06:54:19 +01:00
Add AppInsight logs
This commit is contained in:
@@ -34,6 +34,7 @@ using Hangfire.Annotations;
|
|||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
using Microsoft.ApplicationInsights.AspNetCore.Extensions;
|
||||||
|
|
||||||
namespace BTCPayServer.Hosting
|
namespace BTCPayServer.Hosting
|
||||||
{
|
{
|
||||||
@@ -51,11 +52,12 @@ namespace BTCPayServer.Hosting
|
|||||||
return context.GetHttpContext().User.IsInRole(_Role);
|
return context.GetHttpContext().User.IsInRole(_Role);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public Startup(IConfiguration conf)
|
public Startup(IConfiguration conf, IHostingEnvironment env)
|
||||||
{
|
{
|
||||||
Configuration = conf;
|
Configuration = conf;
|
||||||
|
_Env = env;
|
||||||
}
|
}
|
||||||
|
IHostingEnvironment _Env;
|
||||||
public IConfiguration Configuration
|
public IConfiguration Configuration
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
@@ -99,12 +101,19 @@ namespace BTCPayServer.Hosting
|
|||||||
}
|
}
|
||||||
configuration(config);
|
configuration(config);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
services.AddHangfire(configuration);
|
services.AddHangfire(configuration);
|
||||||
|
|
||||||
|
services.Configure<IOptions<ApplicationInsightsServiceOptions>>(o =>
|
||||||
|
{
|
||||||
|
o.Value.DeveloperMode = _Env.IsDevelopment();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(
|
public void Configure(
|
||||||
IApplicationBuilder app,
|
IApplicationBuilder app,
|
||||||
IHostingEnvironment env,
|
IHostingEnvironment env,
|
||||||
|
IServiceProvider prov,
|
||||||
ILoggerFactory loggerFactory)
|
ILoggerFactory loggerFactory)
|
||||||
{
|
{
|
||||||
if(env.IsDevelopment())
|
if(env.IsDevelopment())
|
||||||
@@ -115,6 +124,10 @@ namespace BTCPayServer.Hosting
|
|||||||
|
|
||||||
|
|
||||||
Logs.Configure(loggerFactory);
|
Logs.Configure(loggerFactory);
|
||||||
|
|
||||||
|
//App insight do not that by itself...
|
||||||
|
loggerFactory.AddApplicationInsights(prov, LogLevel.Information);
|
||||||
|
|
||||||
app.UsePayServer();
|
app.UsePayServer();
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ using System.Net;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using Microsoft.AspNetCore.Hosting.Server.Features;
|
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
namespace BTCPayServer
|
namespace BTCPayServer
|
||||||
@@ -40,13 +41,11 @@ namespace BTCPayServer
|
|||||||
.UseIISIntegration()
|
.UseIISIntegration()
|
||||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||||
.UseConfiguration(conf)
|
.UseConfiguration(conf)
|
||||||
.ConfigureServices(services =>
|
.UseApplicationInsights()
|
||||||
{
|
.ConfigureLogging(l =>
|
||||||
services.AddLogging(l =>
|
|
||||||
{
|
{
|
||||||
l.AddFilter("Microsoft", LogLevel.Error);
|
l.AddFilter("Microsoft", LogLevel.Error);
|
||||||
l.AddProvider(new CustomConsoleLogProvider());
|
l.AddProvider(new CustomConsoleLogProvider());
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.UseStartup<Startup>()
|
.UseStartup<Startup>()
|
||||||
.Build();
|
.Build();
|
||||||
|
|||||||
Reference in New Issue
Block a user