Reputation: 327
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?
Upvotes: 2
Views: 7143
Reputation: 294
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')
Upvotes: 3