Ah nice trick also, didn't think about the cache, but where do you put the code to defie the _init_log ?
On May 19, 11:23 pm, pbreit <[email protected]> wrote: > I got this from here awhile back: > > def _init_log(): > import os,logging,logging.handlers,time > logger = logging.getLogger(request.application) > logger.setLevel(logging.INFO) > handler = logging.handlers.RotatingFileHandler(os.path.join( > request.folder,'logs','applog.log'),'a',1024*1024,1) > handler.setLevel(logging.INFO) #or DEBUG > handler.setFormatter(logging.Formatter( > '%(asctime)s %(levelname)s %(filename)s %(lineno)d %(funcName)s(): > %(message)s')) > logger.addHandler(handler) > return logger > > app_logging = cache.ram('app_wide_log',lambda:_init_log(),time_expire=None) > > Then you can do this from anywhere: > app_logging.info(log_this_data)

