In order to get started you need to install the below library using the pip
command as shown below
pip install logging
After installing this library you need to make an app.py
file and copy paste the following code
app.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import logging def main(): # Configure the logging system logging.basicConfig(filename ='app.log', level = logging.ERROR) # Variables (to make the calls that follow work) hostname = 'www.python.org' item = 'spam' filename = 'data.csv' mode = 'r' # Example logging calls (insert into your program) logging.critical('Host %s unknown', hostname) logging.error("Couldn't find %r", item) logging.warning('Feature is deprecated') logging.info('Opening file %r, mode = %r', filename, mode) logging.debug('Got here') if __name__ == '__main__': main() |