Reputation: 551
I use logging settings as below in the settings.py file:
logging.basicConfig(level=LOG_LEVEL, format=LOG_FORMAT);
handler = logging.handlers.RotatingFileHandler( LOG_FILE_PATH, 'a', LOG_FILE_SIZE,LOG_FILE_NUM );
formatter = logging.Formatter ( LOG_FORMAT );
handler.setFormatter(formatter);
logging.getLogger().addHandler(handler)
and i use mod_python with apache2.
the problem is: when the log rotate, i got many log files created at the same time. for example, i set 5 work-process in apache, and i got log.1, log.2 ... log.5 when it rotate.
any suggestions?
Upvotes: 1
Views: 584
Reputation: 33250
RotatingFileHandler
is not designed to work in multiprocess system. Each process you have notice that file is too large and starts new log, so you get up to 5 new logs. It's not as easy to implement it properly: you have to obtain interprocess lock before creating new file and inform each process to reopen it. You'd better use external (provided with your OS) rotation with server restart or setup single-process logging server.
Upvotes: 2