you can change the format by calling:
logging.basicConfig(format="%(asctime)s %(service_id)s %(
levelname)s %(hostname)s %(host_ip)s %(message)s")
or
logging.basicConfig(
format="%(asctime)s {} %(message)s".format(get_your_hostname_somewhere())
)
the above as pointed by blues comment, would work on the initial setup only.
I believe to get hostname(and all the other fancy data) in there like that you will need to implement a logging.Filter or format it into your logged message if they are defined in the context you call your logger.
After a second review I came across this HOWTO which might be helpful as well, a given example would be something along the lines of:
import logging
# 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 %(service_id)s %(
levelname)s %(hostname)s %(host_ip)s %(message)s')
# add formatter to ch
ch.setFormatter(formatter)
# add ch to logger
logger.addHandler(ch)
logger.info("message")
and on the other file get the logger and define a handler once more, but define the Formatter with the new format.
handler.setFormatter(...)everytime you need a new format?