django logging

发布时间:2019-05-27 22:03:46编辑:auto阅读(1850)

    LOG_LEVEL = 'DEBUG'

     

    LOGGING = {

        'version' : 1,

        'disable_existing_loggers' : True,

        'formatters' : {

                'standard' : {

                    'format' : '%(asctime)s [%(threadName)s:%(thread)d] [%(name)s:%(lineno)d] z [%(levelname)s]- %(message)s'

                },

                'verbose' : {

                    'format' : '[%(asctime)s] %(levelname)-6s %(name)s %(lineno)d %(threadName)s:%(thread)d %(message)s'

                },

        },

        'filters': {

        },

     

        'handlers': {

            'torstatus': {

                'level': LOG_LEVEL,

                'class': 'logging.handlers.RotatingFileHandler',

                'filename': os.path.join(BASE_DIR ,'logs/torstatus.log'), 

                'maxBytes': 1024*1024*5, # 5 MB

                'backupCount': 5,

                'formatter': 'verbose',

            },

            

        },

        'loggers': {

            'torstatus': {

                'handlers': ['torstatus'],

                'level': LOG_LEVEL,

                'propagate': False

            },

        }

    }

     

关键字