Automatic logging proxy with attribute support for .NET service interfaces.
$ dotnet add package Momkay.LoggingProxyA lightweight proxy-based logging interceptor for .NET service interfaces. mIt automatically logs method calls, parameters, execution time, and exceptions — without cluttering your service code.
Task, Task<T>) methods[NoLog] — skip logging[Log(LogLevel.Debug)] — override log levelAddLoggedServices(...)dotnet add package Momkay.LoggingProxy
In your Program.cs (or startup configuration):
using Momkay.LoggingProxy.Core;
builder.Services.AddLoggedServices(typeof(IMyService).Assembly);
This will:
I[ClassName]Scoped lifetime⚠️ You do not need to call
AddScoped<IMyService, MyService>()manually.
public interface IMyService
{
Task DoWorkAsync();
Task InternalHelper();
}
public class MyService : IMyService
{
[Log(LogLevel.Debug)]
public async Task DoWorkAsync()
{
// This will be logged at Debug level
}
[NoLog]
public Task InternalHelper()
{
// This will be skipped in logging
return Task.CompletedTask;
}
}
| Attribute | Description |
|---|---|
[NoLog] | Excludes method from logging |
[Log(Level)] | Overrides log level (default: Info) |
You can log method return values by setting:
Per method:
[Log(includeReturnValue: true)]
public Task<string> GetTokenAsync() { ... }
Globally:
LoggingProxyConfig.LogReturnValuesByDefault = true;
By default, logs are written via ILogger<T>.
For better readability, the proxy includes optional ANSI colors (cyan/green/red) for:
▶✔❌Colors only appear if your console supports ANSI (e.g. VS Code terminal, Windows Terminal, bash).
To disable colors globally:
set LOGGING_PROXY_COLORS=0
IFooService / FooService)Microsoft.Extensions.Logging (already standard in ASP.NET Core)MIT — Use it, extend it, improve it. Contributions welcome!