In [1]:
import logging
In [2]:
FORMAT = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
In [3]:
logging.basicConfig(filename='test.log', format=FORMAT, level=logging.INFO, datefmt='%Y-%m-%d %H:%M%:S')
In [4]:
logger = logging.getLogger("Test")
In [5]:
logger.critical("Logging Critical Log...")
In [6]:
logger.warning("Logging Warning Log...")
In [7]:
logger.info("Logging Info Log...")
In [8]:
logging.shutdown()

Now will see the content of log file test.log

In [9]:
!ls
Logging.html  Logging.ipynb test.log
In [10]:
!cat test.log
2018-05-24 10:14:S - Test - CRITICAL - Logging Critical Log...
2018-05-24 10:14:S - Test - WARNING - Logging Warning Log...
2018-05-24 10:14:S - Test - INFO - Logging Info Log...