Reputation:
I use discord bot with code such as:
import discord
client = discord.Client()
client.run(discord_config["bot_token"])
and logging
module for logging.
My attempt to turn off logging for discord bot:
logging.getLogger("discord").setLevel(logging.WARNING)
However, I still get the logging output in my log file:
DEBUG 2020-05-23 15:20:27,030 - client - event = data_received(<21 bytes>)
DEBUG 2020-05-23 15:20:27,031 - client < Frame(fin=True, opcode=2, data=b'\xc2U\x89\x98Q\\\x89\x98\x8dV"\xe8\x81\r\x00\x00\x00\xff\xff', rsv1=False, rsv2=False, rsv3=False)
DEBUG 2020-05-23 15:20:27,950 - client - event = data_received(<59 bytes>)
DEBUG 2020-05-23 15:20:27,951 - client < Frame(fin=True, opcode=2, data=b'\xc2\x9d\xc1\xcd)\xce\xe0\xe6z\x16\xa6&\xc4W"\xa6\x06\x86\xc6f&Ff&\x96fC\xb9\x1215\x00&\x15\x0b\x03S`\x04PR\x89\x00{\x07\xc0\x0e\xe2p\xa9G\x00\x00\x00\x00\xff\xff', rsv1=False, rsv2=False, rsv3=False)
Upvotes: 2
Views: 824
Reputation: 11
Your attempt should be working, in my code i have
logging.getLogger("discord").setLevel(logging.WARNING)
logging.basicConfig(filename="Debug-Log.txt", level=logging.DEBUG,
format="%(asctime)s:%(levelname)s:%(name)s: %(message)s")
client.logger = logging.getLogger("MyLogger")
client.logger.info("testing1")
Which works perfectly fine, could the messages be coming from a different imported package?
Upvotes: 1