A problem with django logging

27 views
Skip to first unread message

朴诚

unread,
Jan 4, 2016, 7:16:32 AM1/4/16
to Django users
Hi,

I encountered a django logging problem which can not be solved for several hours. My django logging setting is:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,

    'formatters': {
        'standard': {
            'format': '[%(asctime)s - %(name)s - %(levelname)s - %(filename)s:%(lineno)d] %(message)s'
        },
    },

    'handlers': {
        'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
        },

        'file': {
            'level': 'INFO',
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': '%s/logs/django.log' % (BASE_DIR),
            'maxBytes': 1024 * 1024 * 5,
            'backupCount': 5,
            'formatter': 'standard',
        },
    },

    'loggers': {
        'django': {
            'handlers': ['file', 'console'],
            'propagate': True,
            'level': 'DEBUG',
        },
    },
}


and in a .py file which django calls, i write:

logger = logging.getLogger('project.xxx.util')
logger.info('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')

I deploy django with nginx using uwsgi. When I started django, the log file can be created successfully, but no logs will be written to file when executing the py file.
Did anyone have encountered the same problem? Thanks.


Reply all
Reply to author
Forward
0 new messages