Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

logging

import logging
logging.basicConfig(filename='example.log', encoding='utf-8', level=logging.DEBUG)
logging.debug('This message should go to the log file')
logging.info('So should this')
logging.warning('And this, too')
logging.error('And non-ASCII stuff, too, like Øresund and Malmö')
Comment

what is logging in programming

In computing, a log file is a file that records either events that 
occur in an operating system or other software runs, or messages between 
different users of a communication software. Logging is the act of 
keeping a log. ... Many operating systems, software frameworks and 
programs include a logging system.
Comment

# 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.
Comment

LOGGING

import logging
LOG_FILENAME = 'example.log'
logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG)

logging.debug('This message should go to the log file')
Comment

PREVIOUS NEXT
Code Example
Python :: replace all characters in a string python 
Python :: merge multiple excel files with multiple worksheets into a single dataframe 
Python :: run python script on android 
Python :: pandas if else 
Python :: create panda dataframe 
Python :: django login page 
Python :: typing multiple types 
Python :: generate random int python 
Python :: pandas hist normalized 
Python :: media pipe install ERROR: Could not find a version that satisfies the requirement mediapipe (from versions: none) 
Python :: python dict remove duplicates where items are not the same 
Python :: how to calculate the variance of all columns in python 
Python :: Python Selenium import WebElement 
Python :: python string cut last n characters 
Python :: python two string equal 
Python :: python verificar se é numero 
Python :: split string into groups of 3 chars python 
Python :: how to download packages using pip 
Python :: python delete directory contents 
Python :: multiple bars barchart matplotlib 
Python :: how to check if number is negative in python 
Python :: mutiple condition in dataframe 
Python :: python unittest discover 
Python :: gdscript tween 
Python :: python turn positive into negative 
Python :: BURGERS2 solution 
Python :: python requests-session for websites with login 
Python :: importing python module from different directory 
Python :: no module named googlesearch 
Python :: django template add numbers 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =