mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
refactor(logging): ♻ rm Hosting.Abstractions dep
This commit is contained in:
parent
9edd95d3eb
commit
da0806da59
3 changed files with 12 additions and 15 deletions
|
|
@ -21,13 +21,13 @@ public static void AddSharedKernelLogging(this IServiceCollection services, ICon
|
|||
{
|
||||
_ = configuration ?? throw new ArgumentNullException(nameof(configuration));
|
||||
|
||||
//using var serverTelemetryChannel = new ServerTelemetryChannel
|
||||
//{
|
||||
// StorageFolder = configuration.GetSection(ApplicationInsightsOptions.Key)
|
||||
// .Get<ApplicationInsightsOptions>()
|
||||
// .ServerTelemetryChannelStoragePath
|
||||
//};
|
||||
//services.AddSingleton(typeof(ITelemetryChannel), serverTelemetryChannel);
|
||||
using var serverTelemetryChannel = new ServerTelemetryChannel
|
||||
{
|
||||
StorageFolder = configuration.GetSection(ApplicationInsightsOptions.Key)
|
||||
.Get<ApplicationInsightsOptions>()
|
||||
.ServerTelemetryChannelStoragePath
|
||||
};
|
||||
services.AddSingleton(typeof(ITelemetryChannel), serverTelemetryChannel);
|
||||
services.AddApplicationInsightsTelemetry();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
|
|
@ -17,12 +17,11 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.13.1" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.15.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.8" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
|
||||
<PackageReference Include="Serilog.Sinks.ApplicationInsights" Version="3.1.0" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -14,11 +14,9 @@ public static async Task TryRunWithLoggingAsync(this IHost host, Func<Task>? run
|
|||
_ = host ?? throw new ArgumentNullException(nameof(host));
|
||||
|
||||
Log.Logger = ConfigurationBuilder.BaseLoggerConfiguration
|
||||
.WriteTo.Conditional(
|
||||
_ => host.Services.GetService<IHostEnvironment>().IsProduction(),
|
||||
c => c.ApplicationInsights(
|
||||
host.Services.GetRequiredService<TelemetryConfiguration>(),
|
||||
TelemetryConverter.Traces))
|
||||
.WriteTo.ApplicationInsights(
|
||||
host.Services.GetRequiredService<TelemetryConfiguration>(),
|
||||
TelemetryConverter.Traces)
|
||||
.CreateLogger();
|
||||
|
||||
try
|
||||
|
|
|
|||
Loading…
Reference in a new issue