Answers for "# logging"

7

logging.logger

import logging

logging.basicConfig(level=logging.WARNING)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
  
logger.debug("some debugging...")
logger.error("some error...")
Posted by: Guest on December-02-2020
1

# logging

# logging
import logging

# log the execution time and a message of an action
logging.basicConfig(filename='fileName.log',
                    level=logging.INFO,
					format='%(levelname)s:%(asctime)s:%(message)s',
					datefmt="%Y-%m-%d %H:%M:%S")

logging.info('ADD TWO NUMBERS')
print(5+5)

# output in console -> 10
# output in fileName.log -> INFO:2021-12-25 17:47:27:ADD TWO NUMBERS
# Logging is a means of tracking events that happen when some software runs. Logging is important for software developing, debugging and running. If you don’t have any logging record and your program crashes, there are very little chances that you detect the cause of the problem.
Posted by: Guest on March-27-2022

Python Answers by Framework

Browse Popular Code Answers by Language