0

I am trying to output a log file while I run my process in QGIS python. The script I used did not output any log file.

I tried the script below

import logging
formatter = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
logfilename=r'c:\temp\example.log'
logging.basicConfig(filename=logfilename, level=logging.INFO, format=formatter)
logging.info("This logging info text goes into the file")
logging.debug("This logging debug text goes into the file as well")

Expecting a log file to be save in c:\temp\

Er Re
  • 1
  • 2
  • This could be a possible duplicate of https://stackoverflow.com/questions/35898160/logging-module-not-writing-to-file?rq=1. See if this helps you out. – tidakdiinginkan Jan 17 '23 at 18:23
  • I tried and got an error below - AttributeError: module 'logging' has no attribute 'get_logger' – Er Re Jan 18 '23 at 10:51
  • Try `logging.getLogger` instead of `logging.get_logger`. Given how the `print` statement was defined, I believe the SO solution is python 2x compatible whereas `getLogger` is python 3x compatible. – tidakdiinginkan Jan 19 '23 at 07:03
  • No error. But no output file also. I just run the script with an empty file. The print output - [] – Er Re Jan 19 '23 at 12:14

0 Answers0