Save telegram bot logs in a text file

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Save telegram bot logs in a text file



A telegram bot I created in python uses pyTelegramBotAPI API.
To review logs, I was advised to use this line:


logger = telebot.logger



Now I can see my logs only in the terminal I'm running the bot with and when I close this terminal, the log data is lost.



How can I save this logs to a text file?




1 Answer
1



From what I read in documentation here, it should be possible to use Python's handler to logger.



Have you tried something like this


import logging
logger = telebot.logger
telebot.logger.basicConfig(filename='filename.log', level=logging.DEBUG,
format=' %(asctime)s - %(levelname)s - %(message)s')





I got it. thanks
– guygrinberger
Aug 8 at 17:05






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS