<div>I'd like to introduce an option to use asynchronous logging to the common logging module (openstack.common.log). It would default to disabled. Mark McLoughlin recommended that I bring this to the mailing list for discussion and feedback.</div><div><br></div><div>Currently, whenever a log message is sent, the calling greenthread blocks. Where eventlet isn't used at all, the thread blocks. Using eventlet, the other greenthreads get processed while this blocks, but the calling greenthread is blocked all the same.</div><div><br></div><div>My patch addresses this by allowing calling threads/greenthreads to send non-blocking calls to the logger. Log messages will be pushed into the I/O bound handlers in the background. This is done by creating a new subclass of Logger, pushing messages into a process-local, global queue. It creates a thread to pop messages out and send them to the logging handlers. The standard Python Queue module is used, for compatibility and safety with both eventlet and standard Python threading.</div><div><br></div><div><div>It would trivially attach to the existing logging system. It currently activates with the following addition to log.setup():</div></div><div><br></div><div> if CONF.logging_async:</div><div> logging.setLoggerClass(ThreadedLogger)</div><div><br></div><div><br></div><div>Two immediate concerns with my general approach:</div><div> * Log timestamps could be skewed from the time they were emitted.</div><div> - I am looking at generating the messages sooner, but sending them at a delay.</div><div> - Potentially, some logging backends might discard in-message timestamps.</div><div> * Messages will be lost at the destruction of the process unless a wait/cleanup is performed.</div><div> - this can happen now anyway, but less severely.</div><div> - we add a cleanup method.</div><div> - cleanup method doesn't help with more catastrophic failures.</div><div><br></div><div>I'm welcome to hear other questions, concerns and feedback.</div><div><br></div><div><div>Regards,</div><div>Eric Windisch</div><div><br></div></div>