Найти - Пользователи
Полная версия: Configuring Logging как задать символ перевода строки в format
Начало » Python для новичков » Configuring Logging как задать символ перевода строки в format
1
sicvest
есть лог
from configuration import logging

log = logging.getLogger("MyLog")
есть конфигурациооный файл этого лога
format=[%(levelname)s]-%(name)s: %(message)s \n File "%(pathname)s", line %(lineno)d
но перевод на новую строку /n //n \n \\n /r \r не работают, выводятся как есть

причем если сконфигурировать логин без файла, то все работает , например так
# create logger
logger = logging.getLogger("simple_example")
logger.setLevel(logging.DEBUG)
# create console handler and set level to debug
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
# create formatter
formatter = logging.Formatter("%(asctime)s - %(name)s - \n %(levelname)s - %(message)s")
# add formatter to ch
ch.setFormatter(formatter)
# add ch to logger
logger.addHandler(ch)
sicvest
configuration.py
import logging.config 
logging.config.fileConfig("logging.properties")
sicvest
слабо. ни одного ответа, !,,
Ed
Люди отдыхают, лето на дворе :)
Напишите в ваш конфиг вот это:
format=[%(levelname)s]-%(name)s: %(message)s 
File "%(pathname)s", line %(lineno)d
и все у вас будет.
sicvest
Спасибо, работает, чувствовал что тупил, и решение должно быть простым.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB