logger log in logfile and print stdout code example
Example 1: python logging basicconfig stdout
# https://stackoverflow.com/a/14058475
import logging
import sys
root = logging.getLogger()
root.setLevel(logging.DEBUG)
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
root.addHandler(handler)
Example 2: output to log file and error to log error
./ShellFile.sh >& pathToLogFile.log