DEV Community

Cover image for LoggerHelper
Alessandro Chiodo
Alessandro Chiodo

Posted on

LoggerHelper

πŸš€ 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
Enter fullscreen mode Exit fullscreen mode

Or visit the NuGet page.


πŸš€ Quick Start Example

Here’s how simple it is to set up:

  1. 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"
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode
  1. Initialize the logger in your Program.cs:
var logger = LoggerBuilder.BuildFromConfiguration(configuration);
Enter fullscreen mode Exit fullscreen mode

Now the logger will automatically configure all the sinks based on your appsettings.json file.

logger.Information("Application started successfully!");
Enter fullscreen mode Exit fullscreen mode

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)