I am using multiprocessing with python 2.7. I would like each subprocess to log to its own file (filename = procname.pid.log) and NOT to the standarg log output. So far, I have been able to create each log file by creating a logger and FileHandler() in each subprocesses start() method, but I can't stop the log messages from also showing up in the parent log output. I understand that the parent environment is inherited, but how do I shut it off in the child processes?
My child processes are implemented as classes derived from multiprocessing.Process. I have avoided using logging.basicConfig, as I have heard it can only be executed once. I have seen this code suggested:
logger = logging.getLogger(__name__)
logger.propogate = False
But it has no effect.
I am not at all clear how the logging propogates up. I think that when I call getLogger, I have a new logger created called root.__module__
, but I don't know how to get the root to stop printint to the screen.