I'm trying to change all my overused prints, to logging.* mainly because i wanted to have a logfile.
logger = logging.getLogger(__name__) formatter = logging.Formatter("{levelname}:{name}:{message}", style="{") file_handler = logging.FileHandler("log.txt") file_handler.setFormatter(formatter) file_handler.setLevel(logging.DEBUG) logger.addHandler(file_handler) console_handler = logging.StreamHandler() console_handler.setLevel(logging.INFO) console_handler.setFormatter(formatter) logger.addHandler(console_handler) logger.setLevel(logging.DEBUG) Thats the code i have for now, and it's printing to the console correctly but not outputting anything at all to the file. The file even gets created randomly, but but when it does, it's always empty.
I'm using logger.debug() and logger.info(), not the logging.* ones.
Update:
Just copying that same code to an empty script, and importing works as expected. Weird.
Update 2:
I found a question that has the same problem as me, he says he found a solution, but he doesn't share it :(
Update 3:
This is my source. The code gets called by uTorrent everytime the status of a torrent changes. This is the command i have setup in uTorrent:
py C:\Users\Gcq\Downloads\Torrent\torrent.py -n %N -d %D -f %F -p %P -c %S -s %M py because i have shebang at the top of my script that tells py to use python3. I have python2.7 installed too.
And the the commandline otions are the info that uTorrent exposes.
