Skip to content

Commit

Permalink
update app insights
Browse files Browse the repository at this point in the history
  • Loading branch information
damienbod committed Aug 11, 2023
1 parent 05beb7e commit 8612030
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,4 @@ FodyWeavers.xsd

# JetBrains Rider
*.sln.iml
/_logs-uifile.txt
8 changes: 7 additions & 1 deletion AspNetCoreAzureLogging/AspNetCoreAzureLogging.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
Expand All @@ -20,6 +20,12 @@
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
<PackageReference Include="Serilog.Sinks.ApplicationInsights" Version="4.0.0" />
<PackageReference Include="Serilog.Sinks.AzureApp" Version="3.1.0" />

</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions AspNetCoreAzureLogging/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Serilog;
using AspNetCoreAzureLogging;
using Microsoft.ApplicationInsights.Extensibility;

Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
Expand Down
31 changes: 28 additions & 3 deletions AspNetCoreAzureLogging/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,48 @@
"ClientId": "3f1d78ea-06d6-4d77-909f-4d398388e900",
"CallbackPath": "/signin-oidc"
},
//"Serilog": {
// "MinimumLevel": {
// "Default": "Debug",
// "Override": {
// "Microsoft": "Debug",
// "Microsoft.Hosting.Lifetime": "Information",
// "Microsoft.AspNetCore.Authentication": "Debug",
// "System": "Debug"
// }
// }
//},
"Serilog": {
"Using": [ "Serilog.Sinks.AzureApp", "Serilog.Sinks.ApplicationInsights" ],
"MinimumLevel": {
"Default": "Debug",
"Override": {
"Microsoft": "Debug",
"Microsoft.Hosting.Lifetime": "Information",
"Microsoft.AspNetCore.Authentication": "Debug",
"System": "Debug"
}
}
},
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
"WriteTo": [
{
"Name": "AzureApp"
},
{
"Name": "ApplicationInsights",
"Args": {
"telemetryConverter": "Serilog.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter, Serilog.Sinks.ApplicationInsights"
}
}
]
},
"Logging": { // TODO: do we need this for app insights....
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Information"
}
},
"ApplicationInsights": {
"ConnectionString": "[Enter ApplicationInsights Connection String]"
},
"AllowedHosts": "*"
}

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
## Links

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/logging

https://learn.microsoft.com/en-us/azure/azure-monitor/app/ilogger

https://learn.microsoft.com/en-us/azure/azure-monitor/app/tutorial-asp-net-core

0 comments on commit 8612030

Please sign in to comment.