Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python logging error
#1
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?
Reply
#2
What is the output? What are the errors?
Reply
#3
there was some typo error I fixed it. But the file is not overwriting, it is appending though I used filemode='w'.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python logging RotatingFileHandler writes to random file after the first log rotation rawatg 0 409 Feb-15-2024, 11:15 AM
Last Post: rawatg
  Python Logging and Handling phillyfa 2 4,578 Mar-20-2020, 05:13 PM
Last Post: phillyfa
  Python logging RotatingFileHandler and TimedRotatingFileHandler is not working with Q waytosatyam7 2 4,791 Dec-24-2019, 08:44 AM
Last Post: buran
  i am getting error while writing code for exception logging rkgupta51179 1 1,852 Nov-03-2019, 05:12 AM
Last Post: buran
  Logging in python saisankalpj 1 2,425 Nov-12-2018, 05:00 PM
Last Post: ichabod801
  Error while Logging on to outlook email account using Python inside VDI Shilton 0 4,308 Sep-09-2018, 06:53 AM
Last Post: Shilton
  Asynchronous Logging in python 2.7 Elbi 4 8,494 Oct-09-2016, 06:10 PM
Last Post: Elbi

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020