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)
The result is :
ERROR:root:Empty DataFrame
That doesn't look like my formatter
I define stdout and stderr in a service file like this :
StandardOutput=append:/dir/output.txt
StandardError=append:/dir/outputError.txt