Skip to content

Instantly share code, notes, and snippets.

@tzulberti
Created October 12, 2012 18:31
Show Gist options
  • Select an option

  • Save tzulberti/3880707 to your computer and use it in GitHub Desktop.

Select an option

Save tzulberti/3880707 to your computer and use it in GitHub Desktop.
Flask logging error
import logging
from os.path import join
from logging.handlers import TimedRotatingFileHandler
class CURRENT_ENVIRONMENT(object):
LOGGING_FOLDER = '.'
root_logger = logging.getLogger()
root_handler = TimedRotatingFileHandler(
filename=join(CURRENT_ENVIRONMENT.LOGGING_FOLDER, 'web.log'),
when='midnight',
backupCount=10
)
root_handler.setLevel(logging.DEBUG)
root_logger.addHandler(root_handler)
sqlalchemy_logger = logging.getLogger('sqlalchemy')
sql_time_rotating_handler = TimedRotatingFileHandler(
filename=join(CURRENT_ENVIRONMENT.LOGGING_FOLDER, 'sqlalchemy.log'),
when='midnight',
backupCount=10
)
sql_time_rotating_handler.setLevel(logging.DEBUG)
sqlalchemy_logger.addHandler(sql_time_rotating_handler)
app = Flask(__name__)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment