For more information about this configuration, you can see the relevant section of the Django documentation. An example of how you can define a namer and rotator is given in the following snippet, which shows zlib-based compression of the log file: These are not “true” .gz files, as they are bare compressed data, with no “container” such as you’d find in an actual gzip file. This snippet is just for illustration purposes. The following working example shows how logging can be used with multiprocessing using configuration files. The configurations are fairly simple, but serve to illustrate how more complex ones could be implemented in a real mul- tiprocessing scenario. In the example, the main process spawns a listener process and some worker processes. Each of the main process, the listener and the workers have three separate configurations (the workers all share the same configuration). We can see logging in the main process, how the workers log to a QueueHandler and how the listener implements a QueueListener and a more complex logging configuration, and arranges to dispatch events received via the queue to the handlers specified in the configuration. Note that these configurations are purely illustrative, but you should be able to adapt this example to your own scenario. Here’s the script - the docstrings and the comments hopefully explain how it works: (continues on next page) 24 import logging import logging.config import logging.handlers from multiprocessingimport Process, Queue, Event, current_process import os import random import time classMyHandler : """ A simple handler for logging events. It runs in the listener process and dispatches events to loggers based on the name in the received record, which then get dispatched, by the logging system, to the handlers configured for those loggers. """ def handle(self, record): if record.name =="root": def namer(name): return name +".gz" def rotator(source, dest): with open(source,"rb") as sf: data =sf.read() compressed =zlib.compress(data, 9) with open(dest,"wb") as df: df.write(compressed) os.remove(source) rh =logging.handlers.RotatingFileHandler(...) rh .rotator =rotator rh .namer =namer 17 A more elaborate multiprocessing example 16 Using a rotator and namer to customize log rotation processing