Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python log file

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

tail a log file with python

pip or pip3 install sh

from sh import tail
# runs forever
for line in tail("-f", "/var/log/some_log_file.log", _iter=True):
    print(line)
Comment

PREVIOUS NEXT
Code Example
Python :: cpickle python 
Python :: python standard normal cumulative distribution 
Python :: var colors python 
Python :: Python NumPy stack Function Example with 2d array 
Python :: .unique() python 
Python :: Multiple Function in python with input method 
Python :: openpyxl 
Python :: controlling the mouse with pynput 
Python :: get resolution of image python 
Python :: check this id exist in database django 
Python :: stemmer nltk 
Python :: python iterating over a list 
Python :: NumPy roll Example 
Python :: backend in python 
Python :: conda create new env 
Python :: display pil image on kivy canvas 
Python :: pytest create server 
Python :: parse xml in python 
Python :: identity matrix with numpy 
Python :: pandas loop over chunk of rows 
Python :: mongodb and python 
Python :: how should i learn python 
Python :: python remove second occurrence of character in string 
Python :: configuring tailwindcss, vue and laravel 
Python :: pandas switch column levels 
Python :: Reverse an string Using Loop in Python 
Python :: get first digit of number 
Python :: pysimplegui get value from textbox 
Python :: adding numbers in python 
Python :: not using first row as index pandas 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =