CleanWaterServices.LoggingTelemetry 1.0.0.1

dotnet add package CleanWaterServices.LoggingTelemetry --version 1.0.0.1
NuGet\Install-Package CleanWaterServices.LoggingTelemetry -Version 1.0.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CleanWaterServices.LoggingTelemetry" Version="1.0.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CleanWaterServices.LoggingTelemetry --version 1.0.0.1
#r "nuget: CleanWaterServices.LoggingTelemetry, 1.0.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CleanWaterServices.LoggingTelemetry as a Cake Addin
#addin nuget:?package=CleanWaterServices.LoggingTelemetry&version=1.0.0.1

// Install CleanWaterServices.LoggingTelemetry as a Cake Tool
#tool nuget:?package=CleanWaterServices.LoggingTelemetry&version=1.0.0.1

About

The project is a simple library meant to be an extension method leveraged with Serilog for a straightforward, repeatable logging approach throughout an application. Once you implement the library, an agent can allow the code to be telemetered. You must instantiate the Serilog library through your startup independant of these class files to leverage the extension methods.

Installation

You can install it in multiple ways depending on which platform you're using. If you use your default terminal window with the dotnet command line interface.

dotnet add package CleanWaterServices.LoggingTelemetry

If your inside Visual Studio Code or Visual Studio you can leverage their terminal with:

Install-Package CleanWaterServices.LoggingTelemetry

If you would like to use the Visual Studio graphical user interface you can do the following:

  1. Select Project in upper left hand corner.
  2. Choose Manage Nuget Packages
  3. Select browse, then search for CleanWaterServices.LoggingTelemetry

Code Example

public static class IServiceCollection
{
    public static void Register(this IServiceCollection services)
    {
        services.AddLogging(option => option.AddSerilog());
        services.AddSingleton(Log.Logger);
    }
}
public class Startup
{
    public static async Task Main(string[] arguments) => await Host.CreateDefaultBuilder(arguments)
        .ConfigureWebHostDefaults(builder => { builder.UseStartup<Startup>(); })
        .RunConsoleAsync();

    public Startup()
    {
        Log.Logger = new LoggerConfiguration()
            .MinimumLevel.Debug()
            .WriteTo.Console()
            .WriteTo.File($@"{logPath}\log-.txt", rollingInterval: RollingInterval.Day)
            .CreateLogger();
     }
    
    public void ConfigureServices(this IServiceCollection) => services.Register();
}

After you use the above configuration, which couples dependency injection for this particular example, in theory you could use the single line for the extension method. To actually leverage the library:

/* Telemetered Event: */
logger.Capture(LogLevel.Error, "Namespace.Class.Method", exception);

/* Information */
logger.Capture(LogLevel.Information, "Namespace.Class.Method", "A large block", "of text", "that should be iterated", "over multiple lines.");
logger.Capture(LogLevel.Information, "Namespace.Class.Method", "Populate param with a single entry.");

Dependencies:

The project uses the following libraries:

Name Version
Serilog 3.1.1
Serilog.AspNetCore 8.0.1
Serilog.Sinks.Console 5.0.1
Serilog.Sinks.File 5.0.0
Datadog.Trace.Bundle 2.49.0

<br>

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0.1 92 4/20/2024