Momkay.LoggingProxy 1.0.0

There is a newer version of this package available.
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
                    
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="Momkay.LoggingProxy" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Momkay.LoggingProxy" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Momkay.LoggingProxy" />
                    
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 Momkay.LoggingProxy --version 1.0.0
                    
#r "nuget: Momkay.LoggingProxy, 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 Momkay.LoggingProxy@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=Momkay.LoggingProxy&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Momkay.LoggingProxy&version=1.0.0
                    
Install as a Cake Tool

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 method
  • NoLogAttribute 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 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. 
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.2.0 207 5/16/2025
1.0.2 199 5/16/2025
1.0.1 205 5/16/2025
1.0.0 234 5/15/2025