mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
fix(logging): 🐛 try TelemetryConfiguration.CreateDefault()
This commit is contained in:
parent
a0b0b63d69
commit
d87cf6769b
1 changed files with 4 additions and 3 deletions
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.ApplicationInsights;
|
||||
using Microsoft.ApplicationInsights.Extensibility;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Serilog;
|
||||
|
|
@ -13,11 +13,12 @@ public static async Task TryRunWithLoggingAsync(this IHost host, Func<Task>? run
|
|||
{
|
||||
_ = host ?? throw new ArgumentNullException(nameof(host));
|
||||
|
||||
var telemetryClient = (TelemetryClient)host.Services.GetService(typeof(TelemetryClient));
|
||||
Log.Logger = ConfigurationBuilder.BaseLoggerConfiguration
|
||||
.WriteTo.Conditional(
|
||||
_ => host.Services.GetService<IHostEnvironment>().IsProduction(),
|
||||
c => c.ApplicationInsights(telemetryClient, TelemetryConverter.Traces))
|
||||
c => c.ApplicationInsights(
|
||||
TelemetryConfiguration.CreateDefault(),
|
||||
TelemetryConverter.Traces))
|
||||
.CreateLogger();
|
||||
|
||||
try
|
||||
|
|
|
|||
Loading…
Reference in a new issue