I want to write all of python logger messages to a log file. I have this code, but the code displays messages on the console and just creates the log file, but writes nothing to it.
file_handler = logging.FileHandler(filename='tmp.log')
stdout_handler = logging.StreamHandler(sys.stdout)
handlers = [file_handler, stdout_handler]
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p',
handlers=handlers
)
logger = logging.getLogger("somename")
What am i doing wrong here
sys.stdoutto a file rather than to console?sys.stdoutand totmp.log