Answers for "string logger python"

7

create log in python

logging.basicConfig(filename="logfilename.log", level=logging.INFO)
# Log Creation

logging.info('your text goes here')
logging.error('your text goes here')
logging.debug('your text goes here')
Posted by: Guest on October-28-2020
0

python logger exception

# Get Python error information with debug output
# logger.exception outputs a stack trace alongside the error message.

# Example

import logging
try:
    1/0
except ZeroDivisionError:
    logging.exception("error_log")
    
# Outputs
    
ERROR:root:error_log
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
ZeroDivisionError: integer division or modulo by zero
Posted by: Guest on August-12-2021

Python Answers by Framework

Browse Popular Code Answers by Language