Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register Application Insights with Serilog correctly #736

Merged
merged 1 commit into from
Aug 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Source/ApiTemplate/Source/ApiTemplate/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ namespace ApiTemplate
using System.Reflection;
using System.Threading.Tasks;
using Boxed.AspNetCore;
#if ApplicationInsights
using Microsoft.ApplicationInsights.Extensibility;
#endif
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -135,7 +138,9 @@ private static Logger CreateLogger(IHost host)
#if ApplicationInsights
.WriteTo.Conditional(
x => hostEnvironment.IsProduction(),
x => x.ApplicationInsights(TelemetryConverter.Traces))
x => x.ApplicationInsights(
host.Services.GetRequiredService<TelemetryConfiguration>(),
TelemetryConverter.Traces))
#endif
.CreateLogger();
}
Expand Down
7 changes: 6 additions & 1 deletion Source/GraphQLTemplate/Source/GraphQLTemplate/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ namespace GraphQLTemplate
using System.Reflection;
using System.Threading.Tasks;
using Boxed.AspNetCore;
#if ApplicationInsights
using Microsoft.ApplicationInsights.Extensibility;
#endif
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
Expand Down Expand Up @@ -143,7 +146,9 @@ private static Logger CreateLogger(IHost host)
#if ApplicationInsights
.WriteTo.Conditional(
x => hostEnvironment.IsProduction(),
x => x.ApplicationInsights(TelemetryConverter.Traces))
x => x.ApplicationInsights(
host.Services.GetRequiredService<TelemetryConfiguration>(),
TelemetryConverter.Traces))
#endif
.CreateLogger();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ namespace OrleansTemplate.Server
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
#if ApplicationInsights
using Microsoft.ApplicationInsights.Extensibility;
#endif
#if HealthCheck
using Microsoft.AspNetCore.Hosting;
#endif
Expand Down Expand Up @@ -192,7 +195,9 @@ private static Logger CreateLogger(IHost host)
#if ApplicationInsights
.WriteTo.Conditional(
x => hostEnvironment.IsProduction(),
x => x.ApplicationInsights(TelemetryConverter.Traces))
x => x.ApplicationInsights(
host.Services.GetRequiredService<TelemetryConfiguration>(),
TelemetryConverter.Traces))
#endif
.CreateLogger();
}
Expand Down