I am trying to add logging to my script,and followed python logging tutorial
example code
import logging logging.basicConfig(filename='example.log',level=logging.DEBUG) logging.debug('This message should go to the log file') logging.info('So should this') logging.warning('And this, too')
But I cannot find the example.log
file at the directory where the script is in.And as I call os.getcwd()
,it returns C:\\users\\eda
.No log is there either.
There's nothing wrong with your script. However, be clear that the log file will be saved in the same directory as that from which the script was invoked, since you didn't specify an absolute path.
The screenshot below may help clarify this further:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With