The first step is to add the core Loupe Agent to your application via NuGet. To simplify configuration in .NET Core / .NET 5 it's also recommended to add the Loupe Agent Services via NuGet. You can then build on this with additional technology specific agents as you desire.
To extend or modify the configuration of Loupe during application startup, provide a configuration builder method to the AddLoupe call.
Simple Agent Configuration Through Code |
Copy Code
|
---|---|
public class Program { public static void Main(string[] args) { CreateHostBuilder(args).Build().Run(); } public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .AddLoupe(config => { config.Publisher.EnvironmentName = "Demo"; config.NetworkViewer.AllowRemoteClients = true; }); } |
Of course, your application will typically have more lines in your HostBuilder configuration for other parts of your application. For example, if you're using Microsoft.Extensions.Logging as your logging API (or to capture information sent to it by other components of .NET Core) you'll want to add the AddLoupeLogging call to add the Loupe listener so that information is appended to the Loupe log too.
If using the Loupe Agent Builder to extend the Loupe Agent with additional monitoring (for ASP.NET Core, EF Core, and others) you would specify the configuration builder after the agent builder, like this example
Complete HostBuilder Example |
Copy Code
|
---|---|
public class Program { public static void Main(string[] args) { CreateHostBuilder(args).Build().Run(); } public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .AddLoupe(builder => builder.AddAspNetCoreDiagnostics() .AddEntityFrameworkCoreDiagnostics() .AddPerformanceCounters(), config => { config.Publisher.EnvironmentName = "Demo"; config.NetworkViewer.AllowRemoteClients = true; }) .AddLoupeLogging(); } |