Question

I'm trying to debug my view file in Django. I'm using Django 1.3 with mod_python on server.

How can I see some out from my view file. I already try to use standart logging configuration

LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
    'standard': {
        'format' : "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
        'datefmt' : "%d/%b/%Y %H:%M:%S"
    },
},
'handlers': {
    'null': {
        'level':'DEBUG',
        'class':'django.utils.log.NullHandler',
    },
    'logfile': {
        'level':'DEBUG',
        'class':'logging.handlers.RotatingFileHandler',
        'filename': SITE_ROOT + "/logfile",
        'maxBytes': 50000,
        'backupCount': 2,
        'formatter': 'standard',
    },
    'console':{
        'level':'INFO',
        'class':'logging.StreamHandler',
        'formatter': 'standard'
    },
},
'loggers': {
    'django': {
        'handlers':['console'],
        'propagate': True,
        'level':'WARN',
    },
    'django.db.backends': {
        'handlers': ['console'],
        'level': 'DEBUG',
        'propagate': False,
    },
    'customer_portal': {
        'handlers': ['console', 'logfile'],
        'level': 'DEBUG',
    },
}
}

I'm write in my view file:

import logging
log = logging.getLogger('customer_portal')
log.debug("Some data")

But file with log is not created. Thanks for help.

Was it helpful?

Solution

I cut/paste your code and it is working for me. Perhaps there are incorrect permissions on the directory and/or file you are trying to write to?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top