ProcessLogger 1.0.0
dotnet add package ProcessLogger --version 1.0.0
NuGet\Install-Package ProcessLogger -Version 1.0.0
<PackageReference Include="ProcessLogger" Version="1.0.0" />
<PackageVersion Include="ProcessLogger" Version="1.0.0" />
<PackageReference Include="ProcessLogger" />
paket add ProcessLogger --version 1.0.0
#r "nuget: ProcessLogger, 1.0.0"
#:package ProcessLogger@1.0.0
#addin nuget:?package=ProcessLogger&version=1.0.0
#tool nuget:?package=ProcessLogger&version=1.0.0
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
andSystem.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
orfailure
)- 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 | Versions 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. |
-
.NETStandard 2.0
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.5)
-
net8.0
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.5)
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 |