Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python logging - where has the log file gone

Tags:

python

logging

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.

like image 760
Shengxin Huang Avatar asked Oct 18 '22 00:10

Shengxin Huang


1 Answers

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:

Tremendously clarifying screen shot

like image 147
Poiz Avatar answered Oct 20 '22 22:10

Poiz