Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quickstart configuration #20

Merged
merged 8 commits into from
Feb 16, 2024
Merged

Quickstart configuration #20

merged 8 commits into from
Feb 16, 2024

Conversation

Bardin08
Copy link
Owner

@Bardin08 Bardin08 commented Feb 16, 2024

This PR introduces an extension method that allows you to start using Telegram for logging with a single method call with only two params: telegram_bot_token and channel_or_chat_id.

const string botToken = "TELEGRAM_BOT_TOKEN";
const string loggingChatId = "CHANNEL_OR_CHAT_ID";

Log.Logger = new LoggerConfiguration()
    .WriteTo.TelegramCore(
        token: botToken,
        chatId: loggingChatId,
        logLevel: LogEventLevel.Verbose)
    .CreateLogger();


while (true)
{
    var level = Random.Shared.NextInt64(0, 6);
    Log.Logger.Write((LogEventLevel)level, "Message");
    await Task.Delay(500);
}

@Bardin08 Bardin08 self-assigned this Feb 16, 2024
@Bardin08 Bardin08 merged commit a5d2554 into main Feb 16, 2024
@Bardin08 Bardin08 deleted the vbardin/simple-quickstart branch February 16, 2024 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant