Advertisement
codecaine

Logging example

Jul 14th, 2021
1,261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. #importing the module
  2. import logging
  3.  
  4. #now we will Create and configure logger
  5. logging.basicConfig(filename="std.log",
  6.                     format='%(asctime)s %(message)s',
  7.                     filemode='w')
  8.  
  9. #Let us Create an object
  10. logger=logging.getLogger()
  11.  
  12. #Now we are going to Set the threshold of logger to DEBUG
  13. logger.setLevel(logging.DEBUG)
  14.  
  15. #some messages to test
  16. logger.debug("This is just a harmless debug message")
  17. logger.info("This is just an information for you")
  18. logger.warning("OOPS!!!Its a Warning")
  19. logger.error("Have you try to divide a number by zero")
  20. logger.critical("The Internet is not working....")
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement