When i run below code in terminal its create a log file
import logging
logging.basicConfig(filename=\'ramexample.log\',level=logging.DEBUG)
logging.debug(\
The answer why this error happens is this:
The call to
basicConfig()
should come before any calls todebug()
,info()
etc.
If you do so the basicConfig can not create and write a new file.
Here I called logging.info()
right before logging.basicConfig()
.
Don't:
import logging
logging.info("root") # call to info too early
logging.basicConfig(filename="rec/test.log", level=logging.DEBUG) # no file created