How to Add Loggin



Add in your Setting.py

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'console': {
            # exact format is not important, this is the minimum information
            'format': '%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
        },
    },
    'handlers': {
        'file': {
            'level': 'INFO',
            'class': 'logging.FileHandler',
            'filename': 'loggers.log',
            'formatter': 'console',
        },
        'console': {
            'level': 'ERROR',
            'class': 'logging.FileHandler',
            'filename': 'loggers.log',
            'formatter': 'console',
        },
    },
    'loggers': {
        'django': {
            'handlers': ['file'],
            'level': 'INFO',
            'propagate': True,
        },
        'django.db': {
            'handlers': ['console'],
            'level': 'ERROR',
            'propagate': True,
        },
    },
}



add that code for your respeted code in your project

import logging
logger = logging.getLogger(__name__)

Comments

Popular posts from this blog

ERR: error parsing query: found influx, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line

How to get Full URL or get absolute url In Django

How To Convert Html File/URL/String Into Image Using Python