0

I am using Django 1.8 for a project. I have kept the logs in the settings as :

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s \
                %(process)d %(lineno)d %(thread)d %(message)s'
        },
        'simple': {
            'format': '%(levelname)s  %(lineno)d %(message)s'
        },
    },
    'handlers': {
        'null': {
            'level': 'DEBUG',
            'class': 'logging.NullHandler',
            'formatter': 'verbose'
        },
        'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
            'formatter': 'verbose'
        },
        'console_simple': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
            'formatter': 'simple'
        },
        'mail_admins': {
            'level': 'ERROR',
            'class': 'django.utils.log.AdminEmailHandler',
            'formatter': 'verbose'
        },
        'requests': {
            'level': 'INFO',
            'class': 'logging.FileHandler',
            'filename': '/var/log/request.log',
            'formatter': 'verbose'
        },
    },
    'loggers': {
        'django': {
            'handlers': ['null'],
            'propagate': True,
            'level': 'INFO',
        },
        'django.request': {
            'handlers': ['console'],
            'level': 'WARNING',
            'propagate': False,
        },
        'logger': {
            'handlers': ['requests'],
            'level': 'INFO',
            'propagate': False,
        },
    },
}

I get errors regularly as Bad Request, so I want to see what data is sent through the front-end to the function calls.

I want to know if there is a way so that I can store the data sent by the front-end to the functions?Any advances will be appreciated.

the_unknown_spirit
  • 2,518
  • 7
  • 34
  • 56

1 Answers1

0

You can add the loggers to the log the content in log file.

'logfile': {
        'level':'DEBUG',
        'class':'logging.handlers.RotatingFileHandler',
        'filename': SITE_ROOT + "/logfile",
        'maxBytes': 50000,
        'backupCount': 2,
        'formatter': 'standard',
    },

Take a look at Simple Log to File example for django 1.3+

Community
  • 1
  • 1