Kopticx.Logify is a lightweight logging library for C# that implements a custom ILogger with traceable naming, ideal for distributed systems, background workers, and microservices where identifying the log origin is essential.
- 🔧 Custom logger with dynamic naming
- 🧩 Compatible with
Microsoft.Extensions.Logging - 🪄 Simple integration with
Microsoft.Extensions.DependencyInjection - 📦 Published as a NuGet package
- ⚙️ Native AOT (Ahead-of-Time) compatible
- 🧪 Ideal for serverless apps, background jobs, and microservices
Install from NuGet:
dotnet add package Kopticx.LogifyLogify lets you log objects and exceptions without manually serializing them.
It provides convenient extension methods to cover the most common logging scenarios:
logger.LogInformationCustom(new { data, files });
logger.LogInformationCustom("Informative message", new { data, files });
logger.LogErrorCustom(new { data, files }, exception);
logger.LogErrorCustom("Failed to save to DB", new { context = "Import process", id }, exception);These Custom methods have overloads that allow you to include an optional message that is later attached to the final log object.
Here’s how a log entry looks when using LogInformationCustom or LogErrorCustom with a custom object:
[Information] TestLogify:
{
"TrackerId": "490c6df3-eed4-490d-bfe5-c491e9fea278",
"Message": "Informative message",
"CustomObject": {
"data": {},
"files": []
}
}
Add the logger to your DI container:
builder.Services.AddLogify();If you're using Native AOT, register with your custom TypeInfoResolver like this:
var jsonSerializerOptions = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true,
TypeInfoResolver = AppJsonSerializerContext.Default,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
services.AddLogifyService(jsonSerializerOptions);By default, Logify registers as a
Singletonto reuse the sameTrackerIdthroughout the application's lifetime.
You can change the service lifetime toTransientorScopedif you need a differentTrackerIdper HTTP request or instance.
Since Logify extends the native .NET logger, you can simply inject ILogger:
public class Worker(ILogger logger)
{
public Task Run()
{
logger.LogInformationCustom("Hello");
return Task.CompletedTask;
}
}var builder = Host.CreateApplicationBuilder(args);
// Register Logify
builder.Services.AddLogify();
// Register your actual logger provider (Console, AWS, OpenTelemetry, etc.)
// ...
// Sample hosted service
builder.Services.AddHostedService<Worker>();
var app = builder.Build();
app.Run();You can define the logger name using the environment variable:
export loggerName="MyCustomLogger"- If the environment variable
loggerNameis defined, it will be used. - If not, the application name (
System.AppDomain.CurrentDomain.FriendlyName) will be used by default.
TrackedLogger.cs: CustomILoggerimplementation with dynamic namingLogifyExtensions.cs: Extension methods likeLogInformationCustom,LogErrorCustom, etc.LogifyRegistration.cs: Dependency injection registration logic
Logify is fully compatible with Native AOT for optimized, self-contained executables:
<IsAotCompatible>true</IsAotCompatible>📦 nuget.org/packages/Kopticx.Logify
- Log structured objects without manually formatting them
- Add contextual metadata automatically (e.g.,
TrackerId) - Great for debugging, monitoring, and traceability in production
- Simplifies logging in .NET applications