“Logowanie Python BasicConfig Czas” Kod odpowiedzi

Logowanie Pythona do pliku

import logging
import sys

logger = logging.getLogger()
logger.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s | %(levelname)s | %(message)s', 
                              '%m-%d-%Y %H:%M:%S')

stdout_handler = logging.StreamHandler(sys.stdout)
stdout_handler.setLevel(logging.DEBUG)
stdout_handler.setFormatter(formatter)

file_handler = logging.FileHandler('logs.log')
file_handler.setLevel(logging.DEBUG)
file_handler.setFormatter(formatter)

logger.addHandler(file_handler)
logger.addHandler(stdout_handler)
Benja

Logowanie Python BasicConfig Czas

logging.basicConfig(filename='my_log_file.log', format='%(asctime)s - %(message)s', level=logging.INFO)
Bewildered Badger

Odpowiedzi podobne do “Logowanie Python BasicConfig Czas”

Pytania podobne do “Logowanie Python BasicConfig Czas”

Więcej pokrewnych odpowiedzi na “Logowanie Python BasicConfig Czas” w Python

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu