I am using the library logging for my python project and I am trying to separate the logging errors and logging info. Errors and Info are separated, that works.
But the formater is not considered for both of them.
Here is my code. I hope someone already had this issue.
Код: Выделить всё
logger = logging.getLogger('get_data_logger')
logger.setLevel(logging.DEBUG)
stdout_handler = logging.StreamHandler()
stdout_handler.setLevel(logging.INFO)
stderr_handler = logging.StreamHandler()
stderr_handler.setLevel(logging.ERROR)
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
stdout_handler.setFormatter(formatter)
stderr_handler.setFormatter(formatter)
logger.addHandler(stdout_handler)
logger.addHandler(stderr_handler)
Код: Выделить всё
ERROR:root:Empty DataFrame
I define stdout and stderr in a service file like this :
Код: Выделить всё
StandardOutput=append:/dir/output.txt
StandardError=append:/dir/outputError.txt
Источник: https://stackoverflow.com/questions/781 ... oesnt-work