3

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.

1

1 Answer 1

0

Is this on POSIX? Configure your logging after process creation. Then nothing should be inherited by the child processes from the parent process.

BTW note the correct spelling: propagate.

Also, see this post for more information.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.