Skip to content
Add application insights logging to ASP.NET Core apps with one line of code.
C# PowerShell
Branch: dev
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets
src/Serilog.Extensions.Logging.ApplicationInsights
test/Serilog.Extensions.Logging.ApplicationInsights.Tests
.gitattributes
.gitignore
Build.ps1
LICENSE
README.md
appveyor.yml
global.json
serilog-extensions-logging-applicationinsights.sln

README.md

Serilog.Extensions.Logging.ApplicationInsights

Build status NuGet Version

This package makes it a one-liner - loggerFactory.AddApplicationInsights() - to configure top-quality application insights logging for ASP.NET Core apps.

You can get started quickly with this package, and later migrate to the full Serilog API if you need more sophisticated log configuration.

appsettings.json configuration

The log level and instrumentation key can be read from JSON configuration if desired.

In appsettings.json add a "Logging" and "ApplicationInsights" section:

{
  "Logging": {
    "LogLevel": {
      "Default": "Debug",
      "System": "Information",
      "Microsoft": "Information"
    }
  },
  "ApplicationInsights": {
    "InstrumentationKey": "your-Instrumentation-key"
  }
}

And then pass the configuration sections to the AddApplicationInsights() method:

loggerFactory.AddApplicationInsights(Configuration.GetSection("Logging"), Configuration.GetSection("ApplicationInsights"));

HINT: The "Logging" and "ApplicationInsights" sections are standard section already used by netcore.

Using the full Serilog API

This package is opinionated, providing the most common/recommended options supported by Serilog. For more sophisticated configuration, using Serilog directly is recommended.

You can’t perform that action at this time.