ProcessLogger 1.0.0

dotnet add package ProcessLogger --version 1.0.0
                    
NuGet\Install-Package ProcessLogger -Version 1.0.0
                    
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="ProcessLogger" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ProcessLogger" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="ProcessLogger" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ProcessLogger --version 1.0.0
                    
#r "nuget: ProcessLogger, 1.0.0"
                    
#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.
#:package ProcessLogger@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ProcessLogger&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=ProcessLogger&version=1.0.0
                    
Install as a Cake Tool

ProcessLogger

ProcessLogger is a lightweight .NET library for tracking logical operations with structured log messages and optional OpenTelemetry tracing.


βœ… Features

  • πŸ” Logs start / success / failure messages for any logical process
  • ⏱️ Includes duration tracking
  • ⚠️ Exception-safe β€” failures are logged and rethrown
  • βš™οΈ Configurable log levels for start, success, and failure
  • πŸ“‘ Optional OpenTelemetry span generation via ActivitySource
  • πŸ”§ Optional hook to customize each span via ConfigureSpan
  • 🌐 Optional override of ActivitySource to integrate with existing OTEL pipelines
  • πŸ“¦ No external dependencies (uses only ILogger and System.Diagnostics)
  • πŸ§ͺ Compatible with all logging providers (Serilog, NLog, Console, etc.)

πŸš€ Quick Start

Install via NuGet:

dotnet add package ProcessLogger

Use the extension method to wrap a logical process:

await logger.TrackProcessAsync("ImportFile", async () =>
{
    await fileService.DownloadAsync();
    await fileService.ParseAsync();
    await fileService.StoreAsync();
}, metadata: new { FileId = 123 });

Produces logs like:

[ImportFile] Starting process (FileId=123)
[ImportFile] Completed process in 208ms (FileId=123)

On failure:

[ImportFile] Process failed after 89ms (FileId=123): System.Exception: Parse error

βš™οΈ Configuration

You can configure log levels via ProcessLoggerOptions:

var options = new ProcessLoggerOptions
{
    StartLogLevel = LogLevel.Debug,
    SuccessLogLevel = LogLevel.Information,
    FailureLogLevel = LogLevel.Error
};

await logger.TrackProcessAsync("DoThing", async () =>
{
    await DoWorkAsync();
}, options: options);

If no options are provided, sensible defaults are used.


πŸ“‘ OpenTelemetry Integration (Optional)

If your app uses OpenTelemetry, ProcessLogger will automatically:

  • Start an Activity when OpenTelemetry listeners are present
  • Attach tags like:
    • process.status (success or failure)
    • Any thrown exception (as error status)

You can customize the span using ConfigureSpan:

var options = new ProcessLoggerOptions
{
    ConfigureSpan = span =>
    {
        span?.SetTag("custom.tag", "abc123");
        span?.SetStatus(ActivityStatusCode.Error, "manual failure");
    }
};

You can also override the ActivitySource if you're using a shared source:

var options = new ProcessLoggerOptions
{
    ActivitySourceOverride = myCustomSource
};

πŸ”’ Not Using OpenTelemetry? No Problem!

If you're not using OpenTelemetry, you don't need to configure or think about it.
ProcessLogger works perfectly with just logs.
OpenTelemetry features are completely optional and safe to ignore.


πŸ§ͺ Tests

Unit tests are included in the /tests directory and can be run with:

dotnet test

Test coverage includes:

  • Logging behavior with/without metadata
  • Failure propagation
  • Log level customization
  • OpenTelemetry span emission and tagging
  • Custom ActivitySource usage

πŸ“„ License

MIT License. See LICENSE for details.


✨ Credits

Created and maintained by MicheΓ‘l Moriarty.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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 109 5/31/2025