.NET Logging Provider for Telegram — now Open and Extensible

Improved log level filtering

First of all, I updated logs level filtering. Telegram Logger now respects log levels for different namespaces.

var options = new TelegramLoggerOptions
{
...
LogLevel = LogLevel.Information,
...
};
{
"Logging": {
"LogLevel": {
...
},
"Telegram": {
"LogLevel": "Warning",
...
}
},
...
}
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
},
"Telegram": {
"LogLevel": {
"Default": "Error",
"WebApp.Controllers": "Warning"
}
,
...
}
},
...
}

Use custom log writer

Now developers can use their own implementation for writing data to Telegram. Custom writer should implement ILogWriter interface:

var customLogWriter = new CustomLogWriter();
logBuilder.AddTelegram(options, customLogWriter);

Use custom message formatter

For implement custom message formatting ITelegramMessageFormatter can be used now.

private ITelegramMessageFormatter CreateFormatter(string name)
{
return new CustomAceTelegramMessageFormatter(name);
}
logBuilder..AddTelegram(options, CreateFormatter)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andrew Gubskiy

Andrew Gubskiy

Software Engineer, Ph.D., Microsoft MVP in Developer Technologies.