Python logging.handlers.RotatingFileHandler() Examples
The following are 30
code examples of logging.handlers.RotatingFileHandler().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
logging.handlers
, or try the search function
.
![](https://www.programcreek.com/common/static/images/search.png)
Example #1
Source File: config.py From Pytorch-Project-Template with MIT License | 12 votes |
def setup_logging(log_dir): log_file_format = "[%(levelname)s] - %(asctime)s - %(name)s - : %(message)s in %(pathname)s:%(lineno)d" log_console_format = "[%(levelname)s]: %(message)s" # Main logger main_logger = logging.getLogger() main_logger.setLevel(logging.INFO) console_handler = logging.StreamHandler() console_handler.setLevel(logging.INFO) console_handler.setFormatter(Formatter(log_console_format)) exp_file_handler = RotatingFileHandler('{}exp_debug.log'.format(log_dir), maxBytes=10**6, backupCount=5) exp_file_handler.setLevel(logging.DEBUG) exp_file_handler.setFormatter(Formatter(log_file_format)) exp_errors_file_handler = RotatingFileHandler('{}exp_error.log'.format(log_dir), maxBytes=10**6, backupCount=5) exp_errors_file_handler.setLevel(logging.WARNING) exp_errors_file_handler.setFormatter(Formatter(log_file_format)) main_logger.addHandler(console_handler) main_logger.addHandler(exp_file_handler) main_logger.addHandler(exp_errors_file_handler)
Example #2
Source File: Logger.py From DownloaderForReddit with GNU General Public License v3.0 | 7 votes |
def make_logger(): logger = logging.getLogger('DownloaderForReddit') logger.setLevel(logging.DEBUG) stream_formatter = JsonStreamFormatter('%(asctime)s: %(levelname)s : %(name)s : %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p') json_formatter = jsonlogger.JsonFormatter(fmt='%(levelname) %(name) %(filename) %(module) %(funcName) %(lineno) ' '%(message) %(asctime)', datefmt='%m/%d/%Y %I:%M:%S %p') stream_handler = logging.StreamHandler() stream_handler.setLevel(logging.DEBUG) stream_handler.setFormatter(stream_formatter) log_path = os.path.join(SystemUtil.get_data_directory(), 'DownloaderForReddit.log') file_handler = RotatingFileHandler(log_path, maxBytes=1024*1024, backupCount=2) file_handler.setLevel(logging.INFO) file_handler.setFormatter(json_formatter) logger.addHandler(stream_handler) logger.addHandler(file_handler)
Example #3
Source File: app.py From flyingcloud with Apache License 2.0 | 7 votes |
def configure_logging(): namespace = {} namespace['base_dir'] = os.path.abspath(os.path.dirname(__file__)) namespace['logfile'] = os.path.join(namespace['base_dir'], "flask-example.log") logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) rotating_file_handler = RotatingFileHandler(namespace['logfile'], maxBytes=10000, backupCount=20) rotating_file_handler.setLevel(logging.DEBUG) console_stream_handler = logging.StreamHandler() console_stream_handler.setLevel(logging.DEBUG if namespace.get('debug') else logging.INFO) formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') console_stream_handler.setFormatter(formatter) rotating_file_handler.setFormatter(formatter) logger.addHandler(console_stream_handler) logger.addHandler(rotating_file_handler) return logger, rotating_file_handler, console_stream_handler
Example #4
Source File: EcLog.py From FAE with GNU General Public License v3.0 | 7 votes |
def __init__(self, file): Singleton.__init__(self) self.eclogger = logging.getLogger(file) self.eclogger.setLevel(level=logging.DEBUG) if not self.eclogger.handlers: self.rotate_handler = RotatingFileHandler("FECA.log", maxBytes=1024 * 1024, backupCount=5) self.rotate_handler.setLevel(level=logging.DEBUG) DATE_FORMAT = "%m/%d/%Y %H:%M:%S %p" formatter = logging.Formatter(fmt='%(asctime)s(File:%(name)s,Line:%(lineno)d, %(funcName)s) - %(levelname)s - %(message)s', datefmt=DATE_FORMAT) self.rotate_handler.setFormatter(formatter) self.eclogger.addHandler(self.rotate_handler) # def __deepcopy__(self, memodict={}): # copy_object = type(self)("new_FECA.log") # copy_object.rotate_handler = copy.deepcopy(self.rotate_handler, memodict) # copy_object.eclogger = copy.deepcopy(self.eclogger, memodict) # return copy_object
Example #5
Source File: ftpserver.py From oss-ftp with MIT License | 7 votes |
def set_logger(level): #log related work_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) log_dir = work_dir + '/data/ossftp/' mkdir_p(log_dir) LOGFILE = log_dir + "ossftp.log" MAXLOGSIZE = 10*1024*1024 #Bytes BACKUPCOUNT = 30 FORMAT = \ "%(asctime)s %(levelname)-8s[%(filename)s:%(lineno)d(%(funcName)s)] %(message)s" handler = RotatingFileHandler(LOGFILE, mode='w', maxBytes=MAXLOGSIZE, backupCount=BACKUPCOUNT) formatter = logging.Formatter(FORMAT) handler.setFormatter(formatter) logger = logging.getLogger() logger.setLevel(level) logger.addHandler(handler)
Example #6
Source File: test_longrunning_receive.py From azure-event-hubs-python with MIT License | 6 votes |
def get_logger(filename, level=logging.INFO): azure_logger = logging.getLogger("azure.eventhub") azure_logger.setLevel(level) uamqp_logger = logging.getLogger("uamqp") uamqp_logger.setLevel(logging.INFO) formatter = logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s') console_handler = logging.StreamHandler(stream=sys.stdout) console_handler.setFormatter(formatter) if not azure_logger.handlers: azure_logger.addHandler(console_handler) if not uamqp_logger.handlers: uamqp_logger.addHandler(console_handler) if filename: file_handler = RotatingFileHandler(filename, maxBytes=20*1024*1024, backupCount=3) file_handler.setFormatter(formatter) azure_logger.addHandler(file_handler) uamqp_logger.addHandler(file_handler) return azure_logger
Example #7
Source File: probeim.py From im with GNU General Public License v3.0 | 6 votes |
def log_setup(loglevel): tests_path = os.path.dirname(os.path.abspath(__file__)) log_handler = RotatingFileHandler(tests_path + '/log/probeim.log', maxBytes=1048576, backupCount=5) formatter = logging.Formatter('%(asctime)s - %(levelname)s: %(message)s -- %(filename)s::%(funcName)s' ' line %(lineno)d', '%b %d %H:%M:%S') formatter.converter = time.gmtime log_handler.setFormatter(formatter) logger = logging.getLogger() logger.addHandler(log_handler) if loglevel == 'ERROR': lvl = 40 elif loglevel == 'WARNING': lvl = 30 elif loglevel == 'INFO': lvl = 20 elif loglevel == 'DEBUG': lvl = 10 else: lvl = 30 logger.setLevel(lvl)
Example #8
Source File: tcollector.py From scalyr-agent-2 with Apache License 2.0 | 6 votes |
def setup_logging(logfile=DEFAULT_LOG, max_bytes=None, backup_count=None): """Sets up logging and associated handlers.""" LOG.setLevel(logging.INFO) if backup_count is not None and max_bytes is not None: assert backup_count > 0 assert max_bytes > 0 ch = RotatingFileHandler(logfile, "a", max_bytes, backup_count) else: # Setup stream handler. ch = logging.StreamHandler(sys.stdout) ch.setFormatter( logging.Formatter( "%(asctime)s %(name)s[%(process)d] " "%(levelname)s: %(message)s" ) ) LOG.addHandler(ch) # Scalyr edit: Added this override
Example #9
Source File: logger.py From calibre-web with GNU General Public License v3.0 | 6 votes |
def create_access_log(log_file, log_name, formatter): ''' One-time configuration for the web server's access log. ''' log_file = _absolute_log_file(log_file, DEFAULT_ACCESS_LOG) logging.debug("access log: %s", log_file) access_log = logging.getLogger(log_name) access_log.propagate = False access_log.setLevel(logging.INFO) try: file_handler = RotatingFileHandler(log_file, maxBytes=50000, backupCount=2) except IOError: if log_file == DEFAULT_ACCESS_LOG: raise file_handler = RotatingFileHandler(DEFAULT_ACCESS_LOG, maxBytes=50000, backupCount=2) log_file = "" file_handler.setFormatter(formatter) access_log.addHandler(file_handler) return access_log, \ "" if _absolute_log_file(log_file, DEFAULT_ACCESS_LOG) == DEFAULT_ACCESS_LOG else log_file # Enable logging of smtp lib debug output
Example #10
Source File: logger.py From Qzone_Photo with Apache License 2.0 | 6 votes |
def initlogger(self, level, name): """ 初始化logger """ cwd = os.getcwd() formatter = logging.Formatter(self.LOG_FORMAT) logger = logging.getLogger(name) logger.setLevel(level) fh = RotatingFileHandler(os.path.join(cwd, 'logs', name), maxBytes=10 * 1024 * 1024, backupCount=5) fh.setFormatter(formatter) fh.setLevel(level) logger.addHandler(fh) if level is not logging.DEBUG: ch = StreamHandler() ch.setFormatter(formatter) ch.setLevel(level) logger.addHandler(ch) return logger
Example #11
Source File: main.py From pai with Eclipse Public License 2.0 | 6 votes |
def config_logger(logger): logger_level = cfg.LOGGING_LEVEL_CONSOLE if cfg.LOGGING_FILE is not None: logfile_handler = RotatingFileHandler( cfg.LOGGING_FILE, mode='a', maxBytes=cfg.LOGGING_FILE_MAX_SIZE * 1024 * 1024, backupCount=cfg.LOGGING_FILE_MAX_FILES, encoding=None, delay=0 ) logfile_handler.setLevel(cfg.LOGGING_LEVEL_FILE) logfile_handler.setFormatter(logging.Formatter(get_format(logger_level))) logger.addHandler(logfile_handler) logger_level = min(logger_level, cfg.LOGGING_LEVEL_FILE) logconsole_handler = logging.StreamHandler() logconsole_handler.setLevel(cfg.LOGGING_LEVEL_CONSOLE) logconsole_handler.setFormatter(logging.Formatter(get_format(logger_level))) logger.addHandler(logconsole_handler) logger.setLevel(logger_level)
Example #12
Source File: config.py From orchestration with Apache License 2.0 | 6 votes |
def init_logging(): global logger # Setting rotating files number to 5 and each will be of 1MB server_log_file = RotatingFileHandler( LOGGING_FILE, maxBytes=10000, backupCount=5 ) logger = logging.getLogger() ''' Logging level is set to INFO It will log all log messages with INFO, WARNING, ERROR and CRITICAL To enable debug logging, change the INFO to DEBUG Levels hierarchy CRITICAL>ERROR>WARNING>INFO>DEBUG>NOTSET ''' logger.setLevel(logging.INFO) formatter = logging.Formatter(LOGGING_FORMAT) server_log_file.setFormatter(formatter) logger.addHandler(server_log_file)
Example #13
Source File: test_longrunning_send.py From azure-event-hubs-python with MIT License | 6 votes |
def get_logger(filename, level=logging.INFO): azure_logger = logging.getLogger("azure.eventhub") azure_logger.setLevel(level) uamqp_logger = logging.getLogger("uamqp") uamqp_logger.setLevel(logging.INFO) formatter = logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s') console_handler = logging.StreamHandler(stream=sys.stdout) console_handler.setFormatter(formatter) if not azure_logger.handlers: azure_logger.addHandler(console_handler) if not uamqp_logger.handlers: uamqp_logger.addHandler(console_handler) if filename: file_handler = RotatingFileHandler(filename, maxBytes=20*1024*1024, backupCount=3) file_handler.setFormatter(formatter) azure_logger.addHandler(file_handler) uamqp_logger.addHandler(file_handler) return azure_logger
Example #14
Source File: agent.py From heartbeats with MIT License | 6 votes |
def init_log(): logger = logging.getLogger() logger.setLevel(logging.INFO) formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') file_handler = RotatingFileHandler(os.path.join(BASE_DIR, 'log', 'agent.log'), maxBytes=1024 * 1024 * 50, backupCount=10) file_handler.setLevel(logging.INFO) file_handler.setFormatter(formatter) logger.addHandler(file_handler) stream_handler = logging.StreamHandler() stream_handler.setLevel(logging.INFO) stream_handler.setFormatter(formatter) logger.addHandler(stream_handler) return logger
Example #15
Source File: test_longrunning_receive_async.py From azure-event-hubs-python with MIT License | 6 votes |
def get_logger(filename, level=logging.INFO): azure_logger = logging.getLogger("azure.eventhub") azure_logger.setLevel(level) uamqp_logger = logging.getLogger("uamqp") uamqp_logger.setLevel(logging.INFO) formatter = logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s') console_handler = logging.StreamHandler(stream=sys.stdout) console_handler.setFormatter(formatter) if not azure_logger.handlers: azure_logger.addHandler(console_handler) if not uamqp_logger.handlers: uamqp_logger.addHandler(console_handler) if filename: file_handler = RotatingFileHandler(filename, maxBytes=20*1024*1024, backupCount=3) file_handler.setFormatter(formatter) azure_logger.addHandler(file_handler) uamqp_logger.addHandler(file_handler) return azure_logger
Example #16
Source File: test_longrunning_eph_with_context.py From azure-event-hubs-python with MIT License | 6 votes |
def get_logger(filename, level=logging.INFO): azure_logger = logging.getLogger("azure.eventprocessorhost") azure_logger.setLevel(level) uamqp_logger = logging.getLogger("uamqp") uamqp_logger.setLevel(logging.INFO) formatter = logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s') console_handler = logging.StreamHandler(stream=sys.stdout) console_handler.setFormatter(formatter) if not azure_logger.handlers: azure_logger.addHandler(console_handler) if not uamqp_logger.handlers: uamqp_logger.addHandler(console_handler) if filename: file_handler = RotatingFileHandler(filename, maxBytes=20*1024*1024, backupCount=3) file_handler.setFormatter(formatter) azure_logger.addHandler(file_handler) uamqp_logger.addHandler(file_handler) return azure_logger
Example #17
Source File: test_longrunning_send_async.py From azure-event-hubs-python with MIT License | 6 votes |
def get_logger(filename, level=logging.INFO): azure_logger = logging.getLogger("azure.eventhub") azure_logger.setLevel(level) uamqp_logger = logging.getLogger("uamqp") uamqp_logger.setLevel(logging.INFO) formatter = logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s') console_handler = logging.StreamHandler(stream=sys.stdout) console_handler.setFormatter(formatter) if not azure_logger.handlers: azure_logger.addHandler(console_handler) if not uamqp_logger.handlers: uamqp_logger.addHandler(console_handler) if filename: file_handler = RotatingFileHandler(filename, maxBytes=20*1024*1024, backupCount=3) file_handler.setFormatter(formatter) azure_logger.addHandler(file_handler) uamqp_logger.addHandler(file_handler) return azure_logger
Example #18
Source File: __init__.py From azure-event-hubs-python with MIT License | 6 votes |
def get_logger(filename, level=logging.INFO): azure_logger = logging.getLogger("azure.eventhub") azure_logger.setLevel(level) uamqp_logger = logging.getLogger("uamqp") uamqp_logger.setLevel(logging.INFO) formatter = logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s') console_handler = logging.StreamHandler(stream=sys.stdout) console_handler.setFormatter(formatter) if not azure_logger.handlers: azure_logger.addHandler(console_handler) if not uamqp_logger.handlers: uamqp_logger.addHandler(console_handler) if filename: file_handler = RotatingFileHandler(filename, maxBytes=5*1024*1024, backupCount=2) file_handler.setFormatter(formatter) azure_logger.addHandler(file_handler) return azure_logger
Example #19
Source File: nn_config.py From combine-FEVER-NSMN with MIT License | 6 votes |
def get_logger(self): log_file_dir = self.save_path log_file_name = os.path.join(log_file_dir, 'train.log') if not os.path.exists(log_file_dir): os.makedirs(log_file_dir) logger = logging.getLogger() # Debug = write everything logger.setLevel(logging.DEBUG) formatter = logging.Formatter('%(asctime)s :: %(levelname)s :: %(message)s') file_handler = RotatingFileHandler(log_file_name, 'a', 1000000, 1) file_handler.setLevel(logging.INFO) file_handler.setFormatter(formatter) logger.addHandler(file_handler) steam_handler = logging.StreamHandler() steam_handler.setLevel(logging.INFO) logger.addHandler(steam_handler) return logger
Example #20
Source File: yeti_to_elasticsearch.py From yeti with Apache License 2.0 | 6 votes |
def set_logging(): global logger logging.basicConfig(format='%(asctime)s - %(lineno)d - %(funcName)s - %(levelname)s - %(message)s', level=logging.INFO) DEFAULT_JSON_OPTIONS.datetime_representation = 2 logger = logging.getLogger("yeti_to_elastic") formatter = logging.Formatter('%(asctime)s - %(lineno)d - %(funcName)s - %(levelname)s - %(message)s') # You may change here the path for the log file handler = RotatingFileHandler('yeti_to_elastic.log', maxBytes=20000, backupCount=5) handler.setFormatter(formatter) handler.setLevel(logging.INFO) logger.addHandler(handler)
Example #21
Source File: models.py From modmail with GNU Affero General Public License v3.0 | 6 votes |
def configure_logging(name, level=None): global ch_debug, log_level ch_debug = RotatingFileHandler(name, mode="a+", maxBytes=48000, backupCount=1) formatter_debug = FileFormatter( "%(asctime)s %(name)s[%(lineno)d] - %(levelname)s: %(message)s", datefmt="%Y-%m-%d %H:%M:%S", ) ch_debug.setFormatter(formatter_debug) ch_debug.setLevel(logging.DEBUG) if level is not None: log_level = level ch.setLevel(log_level) for logger in loggers: logger.setLevel(log_level) logger.addHandler(ch_debug)
Example #22
Source File: logger.py From micropy-cli with MIT License | 6 votes |
def load_handler(self): """Loads Logging Module Formatting.""" self.log = logging.getLogger() if not self.log.hasHandlers(): self.log.setLevel(logging.DEBUG) self.log_handler = RotatingFileHandler( str(self.LOG_FILE), mode='a', maxBytes=2*1024*1024, backupCount=2, encoding=None, delay=0) self.log_handler.setLevel(logging.DEBUG) self.log.addHandler(self.log_handler) self.log_handler = self.log.handlers[0] log_format = ( "[%(asctime)s] %(levelname)s: " f"{self.service_name.lower()}: " "%(message)s" ) self.log_handler.setFormatter(logging.Formatter(log_format, "%Y-%m-%d %H:%M:%S"))
Example #23
Source File: logging_util.py From schematizer with Apache License 2.0 | 6 votes |
def initialize_uwsgi_logging(log_name, log_directory, log_suffix): """Initialize a logger for the `uwsgi` log, sending output to a rotated file on disk. This is used to log errors in service startup. :param log_name: The name of the log file :param log_directory: The location on disk to write the file to :param log_suffix: The suffix to be appended to the log_name. This is useful for doing things like differentiating different users running the same service. """ global uwsgi_initialized if not uwsgi_initialized: logger = logging.getLogger('uwsgi') complete_log_name = '{0}{1}'.format(log_name, log_suffix) path = os.path.join(log_directory, complete_log_name) handler = RotatingFileHandler(path, maxBytes=102400, backupCount=3) handler.setLevel(logging.INFO) handler.setFormatter(logging.Formatter(DETAILED_FORMAT)) logger.addHandler(handler) uwsgi_initialized = True
Example #24
Source File: utils.py From pastas with MIT License | 6 votes |
def remove_file_handlers(logger=None): """Method to remove any file handlers in the logger of Pastas. Parameters ------- logger : logging.Logger A Logger-instance. Use ps.logger to initialise the Logging instance that handles all logging throughout pastas, including all sub modules and packages. """ if logger is None: logger = logging.getLogger('pastas') for handler in logger.handlers: if isinstance(handler, handlers.RotatingFileHandler): logger.removeHandler(handler)
Example #25
Source File: server.py From PyKMIP with Apache License 2.0 | 6 votes |
def _setup_logging(self, path): # Create the logging directory/file if it doesn't exist. if not os.path.exists(path): if not os.path.isdir(os.path.dirname(path)): os.makedirs(os.path.dirname(path)) open(path, 'w').close() handler = handlers.RotatingFileHandler( path, mode='a', maxBytes=1000000, backupCount=5 ) handler.setFormatter( logging.Formatter( "%(asctime)s - %(name)s - %(levelname)s - %(message)s" ) ) self._logger.addHandler(handler) self._logger.setLevel(logging.DEBUG)
Example #26
Source File: log.py From beibq with BSD 3-Clause "New" or "Revised" License | 6 votes |
def init_logging(app): formatter = logging.Formatter( '%(asctime)s %(levelname)s: %(message)s ' '[in %(pathname)s:%(lineno)d]') error_log = os.path.join(app.root_path, app.config["ERROR_LOG"]) error_file_handler = RotatingFileHandler( error_log, maxBytes = 1024*1024*1024, backupCount = 10 ) error_file_handler.setLevel(logging.ERROR) error_file_handler.setFormatter(formatter) app.logger.addHandler(error_file_handler) info_log = os.path.join(app.root_path, app.config["INFO_LOG"]) info_file_handler = RotatingFileHandler( info_log, maxBytes = 1024*1024*1024, backupCount = 10 ) info_file_handler.setLevel(logging.INFO) info_file_handler.setFormatter(formatter) app.logger.addHandler(info_file_handler) app.logger.setLevel(logging.DEBUG)
Example #27
Source File: logging.py From CumulusCI with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_rot_file_logger(name, path): """Returns a logger with a rotating file handler""" logger = logging.getLogger(name) handler = RotatingFileHandler(path, backupCount=5, encoding="utf-8") handler.doRollover() # rollover existing log files handler.terminator = "" # click.echo already adds a newline logger.addHandler(handler) logger.setLevel(logging.DEBUG) return logger
Example #28
Source File: utils.py From incubator-spot with Apache License 2.0 | 5 votes |
def get_logger(cls, name, level='INFO', filepath=None, fmt=None): ''' Return a new logger or an existing one, if any. :param cls : The class as implicit first argument. :param name : Return a logger with the specified name. :param filepath: Path of the file, where logs will be saved. If it is not set, redirects the log stream to `sys.stdout`. :param fmt : A format string for the message as a whole, as well as a format string for the date/time portion of the message. Default: '%(asctime)s %(levelname)-8s %(name)-34s %(message)s' :rtype : :class:`logging.Logger` ''' logger = logging.getLogger(name) # .............................if logger already exists, return it if logger.handlers: return logger if filepath: # .........................rotate log file (1 rotation per 512KB handler = RotatingFileHandler(filepath, maxBytes=524288, backupCount=8) else: handler = logging.StreamHandler(sys.stdout) fmt = fmt or '%(asctime)s %(levelname)-8s %(name)-34s %(message)s' handler.setFormatter(logging.Formatter(fmt)) try: logger.setLevel(getattr(logging, level.upper() if level else 'INFO')) except: logger.setLevel(logging.INFO) logger.addHandler(handler) return logger
Example #29
Source File: peanuts.py From peanuts with MIT License | 5 votes |
def LoggingOfData(output): # setup our rotating logger if os.path.isfile(output) == False: f = open(output,'w') f.write('Time, Device, MAC Address, Manufacture, SSID, Crypto, Latitude, Longitude, Location, RSSI\n') f.close() global logger logger = logging.getLogger(NAME) logger.setLevel(logging.INFO) handler = RotatingFileHandler(output, maxBytes=10000000, backupCount=99999) logger.addHandler(handler)
Example #30
Source File: test_cases.py From cloudify-manager with Apache License 2.0 | 5 votes |
def _set_file_handler(path): mega = 1024 * 1024 if not os.path.isdir(path): raise IOError('dir does not exist') path = os.path.join(path, 'integration_tests_framework.log') handler = RotatingFileHandler(path, maxBytes=5 * mega, backupCount=5) handler.setLevel(logging.DEBUG) return handler