Momkay.LoggingProxy
1.0.0
See the version list below for details.
dotnet add package Momkay.LoggingProxy --version 1.0.0
NuGet\Install-Package Momkay.LoggingProxy -Version 1.0.0
<PackageReference Include="Momkay.LoggingProxy" Version="1.0.0" />
<PackageVersion Include="Momkay.LoggingProxy" Version="1.0.0" />
<PackageReference Include="Momkay.LoggingProxy" />
paket add Momkay.LoggingProxy --version 1.0.0
#r "nuget: Momkay.LoggingProxy, 1.0.0"
#:package Momkay.LoggingProxy@1.0.0
#addin nuget:?package=Momkay.LoggingProxy&version=1.0.0
#tool nuget:?package=Momkay.LoggingProxy&version=1.0.0
Momkay.LoggingProxy
A lightweight proxy-based logging interceptor for .NET service interfaces. It automatically logs method calls, parameters, execution time, and exceptions — without cluttering your service code.
Features
- Logs method entry, arguments, and exit duration
- Logs exceptions with full context
- Attribute-based control:
[NoLog]
— skip logging[Log(LogLevel.Debug)]
— override log level per method
- Compatible with any DI container using interfaces
- No external dependencies or runtime reflection libraries
Installation
Add the NuGet package to your project:
dotnet add package Momkay.LoggingProxy
Setup
In your Program.cs (or wherever you configure services):
using Momkay.LoggingProxy.Core;
builder.Services.AddLoggedServices(typeof(IMyService).Assembly);
This scans all types in the specified assembly and wraps matching service interfaces in logging proxies.
A service will be automatically wrapped if:
- It has an interface named
I[ClassName]
- It is registered in DI via that interface
Usage example
Interface
public interface IMyService
{
Task DoWorkAsync();
Task InternalHelper();
}
Implementation
public class MyService : IMyService
{
[Log(LogLevel.Debug)]
public async Task DoWorkAsync()
{
// This method call will be logged with Debug level
}
[NoLog]
public Task InternalHelper()
{
// This method will not be logged
return Task.CompletedTask;
}
}
Attributes
You can fine-tune logging behavior using these attributes:
LogAttribute
Sets the log level for a specific methodNoLogAttribute
Disables logging entirely for the method
These attributes are optional. By default, all public interface methods are logged at Information level.
Requirements
- .NET 6 or later or .NET Standard 2.1 (for libraries)
- Interface-based service registration (e.g. IService, Service)
- Microsoft.Extensions.Logging in your app (standard in ASP.NET Core)
Product | Versions 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. 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. |
-
net8.0
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.