logging config fileconfig('applogconfig ini'as beforemodules that want to issue log messages do not need to worry about the details of loading the logging configuration they merely import the logging module and get reference to the appropriate logger object for exampleimport logging app_log logging getlogger("app"app_log critical("an error occurred"performance considerations adding logging to an application can severely degrade its performance if you aren' careful howeverthere are some techniques that can be used to reduce the overhead firstpython' optimized mode (-oremoves all code that is conditionally executed using statements such as if _debug_ _statements if the sole purpose of logging is debuggingyou could conditionally execute all of the logging calls and have the calls removed in optimized mode second technique would be to use null object in place of logger object when logging is to be completely disabled this is different than using none insteadyou want to use an instance of an object that silently swallows all operations that get performed on it for exampleclass null(object)def _init_ (self*args**kwargs)pass def _call_ (self*args**kwargs)return self def _getattribute_ (selfname)return self def _setattr_ (selfnamevalue)pass def _delattr_ (self,name)pass log null(log critical("an error occurred "does nothing depending on your clevernesslogging can also be managed through the use of decorators and metaclasses because these features of python operate at the time that functionsmethodsand classes are definedthey can be used to selectively add or remove logging features from parts of program in way that does not impact performance when logging is disabled please refer to "functions and functional programming,and "classes and object-oriented programming,for further details notes the logging module provides large number of customization options not discussed here readers should consult online documentation for further details it is safe to use the logging module with programs that use threads in particularit is not necessary to add locking operations around code that is issuing log messages mmap the mmap module provides support for memory-mapped file object this object behaves both like file and byte string and can be used in most places where an ordif lib fl ff