Wednesday 16 October 2019

Logging module in python

import logging

##Logging Basic Configurations
logging.basicConfig(filename="Scriptlog.log" , format='%(asctime)s %(message)s', filemode='w')
logger = logging.getLogger('logger')
logger.setLevel(logging.INFO) #Log Level can be changed to DEBUG, ERROR, WARNING etc.

##Put below logger where you want logging
logger.info("Python script has been completed")


No comments:

Post a Comment