Quick guide to Logging in different files using Python

This is for quick setup of a logging system . 

Step 1: import logging 

Logging is the build-in module for implementing logging in Python.

Step 2: Create a logger for yourself. 

logger = logging.getLogger(__name__)

Step 3: Set Logger level


Step 4: Create a handler. 

hdlr = logging.FileHandler(settings.BASE_LOG_FILE, mode='w')

Step 5: Create a formatter

formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')

Step 6: Set formatter and handler



Popular posts from this blog

Why should you visit Kashmir sooner?

CNTLM in Office

Rajasthan: The Best backpacking destination in India