operating system services thusif you pass single dictionary as an argumentthe format string can include dictionary key names here are few examples that illustrate how this workslog logging getlogger("app" log message using positional formatting log critical("can' connect to % at port % "hostporta log message using dictionary formatting parms 'host'www python org''port log critical("can' connect to %(host) at port %(port) "parmsthe keyword argument exc_infoif set to trueadds exception information from sys exc_info(to the log message if exc_info is set to an exception tuple such as that returned by sys exc_info()then that information is used the extra keyword argument is dictionary that supplies additional values for use in log message format strings (described laterboth exc_info and extra must be specified as keyword arguments when issuing log messagesyou should avoid code that carries out string formatting at the time the message is issued (that isformatting message and then passing the result into the logging modulefor examplelog critical("can' connect to % at port % (hostport)in this examplethe string formatting operation always occurs before the call to log critical(because the arguments to function or method have to be fully evaluated howeverin the example at the top of the pagethe parameters used for string formatting operation are merely passed to the logging module and used only if the log message is actually going to be handled this is very subtle distinctionbut because many applications choose to filter log messages or only emit logs during debuggingthe first approach performs less work and runs faster when logging is disabled in addition to the methods shownthere are few additional methods for issuing log messages on logger instance log log exception(fmt [*args ]issues message at the error level but adds exception information from the current exception being handled this can only be used inside except blocks log log(levelfmt [*args [exc_info [extra]]]issues logging message at the level specified by level this can be used if the logging level is determined by variable or if you want to have additional logging levels not covered by the five basic levels log findcaller(returns tuple (filenamelinenofuncnamecorresponding to the caller' source filenameline numberand function name this information is sometimes useful when issuing log messages--for exampleif you want to add information about the location of the logging call to message lib fl ff