Add the the following NuGet packages to get Loupe and its relevant dependencies:
- Loupe.Agent.Core.Services: A small package with configuration builders for .NET Core.
- Loupe.Extensions.Logging (Optional): Connects Loupe with the Microsoft.Extensions.Logging infrastructure which is used by .NET for common logging.
- Loupe.Agent.EntityFrameworkCore (Optional): Connects Loupe with EF Core to record performance and diagnostic information for EF Core.
- Loupe.Agent.PerformanceCounters (Optional): Records a collection of Windows Performance Counters on Windows systems.
The recommended way to activate the Loupe Agent is to add it to the Host Builder setup, typically in Program.cs, like this:
Host Builder Example for Program.cs |
Copy Code
|
---|---|
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .AddLoupe(builder => builder.AddEntityFrameworkCoreDiagnostics() .AddPerformanceCounters()) .AddLoupeLogging(); |
.NET Core uses a different, more flexible, approach to application configuration than .NET Framework applications. Instead of XML config files .NET Core has an entire extensible configuration subsystem that can be used. In most situations you'll do a combination of coded configuration and JSON configuration. For details, see Developer's Guide - Agent Configuration.
Once you've instrumented an application you'll want to set up a connection with Loupe Server so you can collect data from everywhere your application runs and start managing errors. Add this configuration to your appsettings.json file to send data to this server automatically in the background. You'll need to make a few changes to this JSON to have it work:
- Replace "Your Loupe Service Name" with the name of your Loupe Cloud-hosted Service. If you don't have one yet, sign up for a free trial service.
- Replace "Your Product" and "Your Application" with friendly values for your application. A good analogy for Product is "Office" and Application is "Word", "Excel", and "PowerPoint".
{ "Logging": { "IncludeScopes": false, "LogLevel": { "Default": "Warning" } }, "Loupe": { "Publisher": { "ProductName": "Your Product", "ApplicationName": "Your Application", "ApplicationType": "AspNet", "ApplicationVersionNumber": "1.0.1" }, "Server": { "UseGibraltarService": true, "CustomerName": "Your Loupe Service Name", "AutoSendSessions": true, "SendAllApplications": true } } }