• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

LoggerHelper

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
? 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

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

.

? 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"
}
}
}
}
  1. 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:

?

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



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.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу