Python Forum

Full Version: Python logging error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
I am running the below code to print the log.
python version is: Out[11]: '3.6.8 |Anaconda 4.3.1 (64-bit)| (default, Feb 21 2019, 18:30:04) [MSC v.1916 64 bit (AMD64)]'

import logging

logging.basicConfig(level=logging.DEBUG,
                    format='%(asctime)s:%(levelname)s: %(message)s',
                    filename='mylog.txt',
                    filemode='w')
logging.debug('A debug message')
logging.info('Info message')
logging.warning('Warning message')
it giving errors. Someone help me how to fix it?
What is the output? What are the errors?
there was some typo error I fixed it. But the file is not overwriting, it is appending though I used filemode='w'.