advanced logging implementing the filter(method this method takes log record this log record can be validated to determine if the record should be output or not if it should be output then true is returnedif the record should be ignored false should be returned in the following examplea filter called myfilter is defined that will filter out all log messages containing the string 'johnit is added as filter to the logger and then two log messages are generated import logging class myfilter(logging filter)def filter(selfrecord)if 'johnin record msgreturn false elsereturn true logging basicconfig(format='%(asctime) %(message) 'level=logging debuglogger logging getlogger(logger addfilter(myfilter()logger debug('this is to help with debugging'logger info('this is information on john'the output shows that only the log message that does not contain the string 'johnis output : : , this is to help with debugging logger configuration all the examples so far in this have used programmatic configuration of the logging framework this is certainly feasible as the examples showbut it does require code change if you wish to alter the logging level for any particular loggeror to change where particular handler is routing the log messages for most production systems better solution is to use an external configuration file which is loaded when the application is run and is used to dynamically configure the logging framework this allows system administrators and others to change the log levelthe log destinationthe log format etc without needing to change the code