```python
#
example.pyimport logging
import multiprocessing
import os
_logger = logging.getLogger(__name__)
def init_logging():
# create logger
root_logger = logging.getLogger()
root_logger.setLevel(logging.DEBUG)
# create file handler
log_file = 'my_log_{}.log'.format(os.getpid())
file_handler = logging.FileHandler(log_file)
file_handler.setLevel(logging.DEBUG)
# create formatter
formatter = logging.Formatter('%(asctime)s - %(process)d - %(name)s - %(levelname)s - %(message)s')
file_handler.setFormatter(formatter)
# add file handler to logger
root_logger.addHandler(file_handler)
def start():
init_logging()
from . import file1, file2
file1.say_hello()
file2.say_hello()
def main():
processes = []
for i in range(4):
p = multiprocessing.Process(target=start)
processes.append(p)
p.start()
for p in processes:
p.join()
if __name__ == '__main__':
main()
#
file1.pyimport logging
_logger = logging.getLogger(__name__)
def say_hello():
_logger.info("this is hello message from
file1.py")
#
file2.pyimport logging
_logger = logging.getLogger(__name__)
def say_hello():
_logger.info("this is hello message from
file2.py")
```