π Introducing CSharpEssentials.LoggerHelper: A Modular and Powerful Logger for .NET Developers
In the world of software development, structured and reliable logging is crucial for debugging, monitoring, and maintaining applications.
Today, I'm excited to introduce CSharpEssentials.LoggerHelper, a lightweight, modular library built on top of Serilog, designed to make logging in .NET applications easier, cleaner, and more powerful.
π¦ What is LoggerHelper?
LoggerHelper is a wrapper around Serilog that allows you to configure multi-sink logging quickly and flexibly, without having to write complex boilerplate code.
It helps you set up a professional logging system with:
- Console
- File
- PostgreSQL
- Telegram
β¦ and it's easy to extend with your own custom sinks!
π Key Features
β
Modular Configuration
With the LoggerBuilder
, you can configure exactly the sinks you need β no unnecessary setup.
β
Standardized Log Format
Every log automatically includes essential fields like:
Action
IdTransaction
ApplicationName
MachineName
β
.NET 8 Compatible
Built for modern applications, ready for production.
β
Lightweight and Performant
No heavy dependencies, only the essentials.
β
Telegram Notifications
Receive critical logs directly on Telegram in real-time!
π οΈ How to Install
You can install LoggerHelper directly from NuGet:
dotnet add package CSharpEssentials.LoggerHelper
Or visit the NuGet page.
π Quick Start Example
Hereβs how simple it is to set up:
- Define your logging configuration in
appsettings.json
:
{
"LoggerHelper": {
"ApplicationName": "MyApp",
"Sinks": {
"Console": {
"Enabled": true
},
"File": {
"Enabled": true,
"Path": "logs/log-.txt"
},
"PostgreSQL": {
"Enabled": true,
"ConnectionString": "your-connection-string"
},
"Telegram": {
"Enabled": true,
"BotToken": "your-bot-token",
"ChatId": "your-chat-id"
}
}
}
}
- Initialize the logger in your
Program.cs
:
var logger = LoggerBuilder.BuildFromConfiguration(configuration);
Now the logger will automatically configure all the sinks based on your appsettings.json
file.
logger.Information("Application started successfully!");
You can enable or disable sinks dynamically just by changing the settings β no need to modify the code!
π Important
LoggerHelper is designed to be configuration-driven, keeping your application code clean and letting you control the behavior through simple settings.
π§© Extending LoggerHelper
LoggerHelper is designed to be easily extendable.
If you want to add a new sink or customize your logs:
- You can create your own extension methods.
- You can inject contextual properties dynamically.
- You can customize the enrichment to match your domain requirements.
β¨ Why Use LoggerHelper Instead of Raw Serilog?
- Less Setup: No more cluttered Program.cs with tons of configuration.
- Consistency: Always log the most critical context fields automatically.
- Flexibility: Add or remove sinks in a modular way.
- Productivity: Focus on your business logic β not on writing logger configuration.
π Documentation & GitHub
You can find full examples, usage tips, and source code on GitHub:
π https://github.com/alexbypa/CSharp.Essentials
Feel free to open issues, suggest improvements, or contribute!
π₯ Conclusion
If you're looking for a clean, modular, and extensible logging solution for your .NET projects,
CSharpEssentials.LoggerHelper is made for you.
Itβs simple enough for small applications, yet powerful enough for enterprise-grade systems.
If you find it useful, consider leaving a β on GitHub β it really helps the project grow!
π¬ Have questions or suggestions? Feel free to leave a comment below! I'd love to hear your feedback.
Top comments (0)