mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
fix(logging): 🐛 try fix AppInsights logging via alt WriteTo.ApplicationInsights overload
This commit is contained in:
parent
6f8d5da9c9
commit
47da43e29f
2 changed files with 4 additions and 15 deletions
|
|
@ -1,5 +1,4 @@
|
|||
using Microsoft.ApplicationInsights;
|
||||
using Serilog;
|
||||
using Serilog;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace FilterLists.SharedKernel.Logging
|
||||
|
|
@ -12,13 +11,7 @@ internal static class ConfigurationBuilder
|
|||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
|
||||
.MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning)
|
||||
.Enrich.FromLogContext()
|
||||
.WriteTo.Console();
|
||||
|
||||
public static LoggerConfiguration WriteToApplicationInsights(
|
||||
this LoggerConfiguration loggerConfiguration,
|
||||
TelemetryClient telemetryClient)
|
||||
{
|
||||
return loggerConfiguration.WriteTo.ApplicationInsights(telemetryClient, TelemetryConverter.Traces);
|
||||
}
|
||||
.WriteTo.Console()
|
||||
.WriteTo.ApplicationInsights(TelemetryConverter.Traces);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.ApplicationInsights;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Serilog;
|
||||
|
||||
|
|
@ -12,10 +11,7 @@ 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
|
||||
.WriteToApplicationInsights(telemetryClient)
|
||||
.CreateLogger();
|
||||
Log.Logger = ConfigurationBuilder.BaseLoggerConfiguration.CreateLogger();
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue