This service is for businesses that have multiple microservices. The service makes it easier to manage the microservice and to develop and debug the service.

Features

Centralized Logging

Getting Started in .Net / C#

Make sure you have the lastest CopylHelper nuget package installed.

Install-Package CopylHelper -Version 8.2.5

Add logging config to appsettings.json

{
  "AppSettings": {
    "ServiceId": "*YOUR_SECRETS*",
    "AppId": "*YOUR_SECRETS*",
    "AppName": "*YOUR_SECRETS*",
    "ApiKey": "*YOUR_SECRETS*",
    "EnterpriseId": "*YOUR_SECRETS*",
    "OcpApimSubscriptionKey": "*YOUR_SECRETS*",
	 },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Warning",
      "CopylAPI_Users": "Information"
    },
    "CopylLoggerProvider": {
      "IncludeScopes": true,
      "LogLevel": {
        "Default": "Information",
        "Microsoft": "Error",
        "CopylAPI_Users": "Information"
      }
    }
  },

Set up program.cs

public class Program
{
    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
        .ConfigureLogging((hostingContext, logging) =>
    {
        logging.ClearProviders();
        logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
        Guid? appId = null; // Initialize nullable Guid for AppId.
        // Retrieve CopylSettings safely
        CopylHelper.Entities.AppSettings copylSettings = hostingContext.Configuration.GetSection("AppSettings").Get<CopylHelper.Entities.AppSettings>();
        if (!string.IsNullOrEmpty(copylSettings?.AppId))
        {
            appId = new System.Guid(copylSettings.AppId);
        }
        // Use fallback values if ServiceId or OcpApimSubscriptionKey are not defined
        string serviceId = copylSettings?.ServiceId ?? string.Empty; // Fallback to Guid.Empty if ServiceId is not defined
        string ocpApimSubscriptionKey = copylSettings?.OcpApimSubscriptionKey ?? string.Empty; // Fallback to empty string if OcpApimSubscriptionKey is not defined

        logging.AddProvider(new CopylLoggerProvider(
            new CopylLoggerConfiguration
            {
                ServiceId = new Guid(serviceId), // Using the safe value of ServiceId
                UserId = null,
                AppId = appId, // Using the safe value of AppId
                LogLevel = LogLevel.Information,
                OcpApimSubscriptionKey = ocpApimSubscriptionKey // Using the safe value of OcpApimSubscriptionKey
            }));
    }

Test the logging