Python Forum
Python logging error - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Python logging error (/thread-27865.html)



Python logging error - Mekala - Jun-25-2020

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?


RE: Python logging error - bowlofred - Jun-25-2020

What is the output? What are the errors?


RE: Python logging error - Mekala - Jun-25-2020

there was some typo error I fixed it. But the file is not overwriting, it is appending though I used filemode='w'.