Python Logging Example - Python

What is python logging?

Snippet Code

Rate this page :
  [ 0 votes]

Logging is a way to track events which happen when some software runs. Here, using basicConfig() function, a default handler is created, so that debug messages are written to a file. If your file have permissions to read and write, then example.log file will be created in the current directory.

import logging LOG_FILENAME = 'example.log' logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG) logging.debug('This message should go to the log file')


Ask Questions

Ask Question