Consider a multi threaded python application using python logger module. I want to do per thread logging, so I have appended the a unique-ID (not thread id) at the bottom of
A potential solution would be to replace getLogger:
import logging
old_getlogger= logging.getLogger
def my_getlogger(name):
return old_getlogger( (str(someInt) if name==__name__ else "") + name)
logging.getLogger= my_getlogger
You'll need to make sure someInt has the correct value though, which may be hard, depending on the structure of your code. @Marek 's suggestion of using thread local storage may be useful for that.