operating system services log critical("could not connect to server"extra=netinfothe downside of this approach is that you have to make sure every logging operation includes the extra information or else the program will crash an alternative approach is to use the logadapter class as wrapper for an existing logger logadapter(log [extra]creates wrapper around logger object log extra is dictionary of extra context information to be supplied to message formatters an instance of logadapter has the same interface as logger object howeveroperations that issue log messages will automatically add the extra information supplied in extra here is an example of using logadapter objectimport loggingsocket logging basicconfigformat "%(hostname) %(levelname)- %(asctime) %(message)ssome extra context netinfo 'hostnamesocket gethostname()'ipsocket gethostbyname(socket gethostname()create logger log logging logadapter(logging getlogger("app")netinfoissue log message extra context data is supplied by the logadapter log critical("could not connect to server"miscellaneous utility functions the following functions in logging control few other aspects of loggingdisable(levelglobally disables all logging messages below the level specified in level this can be used to turn off logging on applicationwide basis--for instanceif you want to temporarily disable or reduce the amount of logging output addlevelname(levellevelnamecreates an entirely new logging level and name level is number and levelname is string this can be used to change the names of the built-in levels or to add more levels than are supported by default getlevelname(levelreturns the name of the level corresponding to the numeric value level shutdown(shuts down all logging objectsflushing output if necessary logging configuration setting an application to use the logging module typically involves the following basic steps use getlogger(to create various logger objects set parameters such as the lib fl ff