mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
add AppInsights ILogger sink
This commit is contained in:
parent
89848926bf
commit
91c6ba5513
2 changed files with 30 additions and 1 deletions
|
|
@ -32,13 +32,25 @@
|
|||
<PackageReference Include="LibGit2Sharp" Version="0.26.0" />
|
||||
<PackageReference Include="MediatR" Version="7.0.0" />
|
||||
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.10.0" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.10.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.3" />
|
||||
<PackageReference Include="Microsoft.DotNet.Analyzers.Compatibility" Version="0.2.12-alpha" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.2.4" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.10.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.2.0" />
|
||||
<PackageReference Include="RestSharp" Version="106.6.9" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="appsettings.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -1,10 +1,12 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Autofac;
|
||||
using Autofac.Extensions.DependencyInjection;
|
||||
using FilterLists.Agent.Infrastructure;
|
||||
using FilterLists.Agent.ListArchiver;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
|
|
@ -26,10 +28,16 @@ public static async Task Main()
|
|||
|
||||
private static void RegisterServices()
|
||||
{
|
||||
var configuration = GetConfiguration();
|
||||
var serviceCollection = new ServiceCollection();
|
||||
|
||||
// register Agent services
|
||||
serviceCollection.AddLogging(b => b.AddConsole());
|
||||
//serviceCollection.AddSingleton(configuration);
|
||||
serviceCollection.AddLogging(b =>
|
||||
{
|
||||
b.AddConsole();
|
||||
b.AddApplicationInsights(configuration["ApplicationInsights:InstrumentationKey"]);
|
||||
});
|
||||
serviceCollection.AddMediatR(typeof(Program).Assembly);
|
||||
serviceCollection.AddHttpClient<AgentHttpClient>();
|
||||
serviceCollection.AddSingleton<IFilterListsApiClient, FilterListsApiClient>();
|
||||
|
|
@ -39,5 +47,14 @@ private static void RegisterServices()
|
|||
var container = containerBuilder.Build();
|
||||
_serviceProvider = new AutofacServiceProvider(container);
|
||||
}
|
||||
|
||||
private static IConfigurationRoot GetConfiguration()
|
||||
{
|
||||
return new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json", true, false)
|
||||
.AddEnvironmentVariables()
|
||||
.Build();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue