mkocubinski
mkocubinski

Reputation: 455

Why is this logging configuration not printing to stdout?

LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
    'verbose': {
        'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
    },
    'simple': {
        'format': '%(levelname)s %(message)s'
    }
},
'handlers': {
    'console': {
        'level':'DEBUG',
        'class':'logging.StreamHandler',
        'strm': sys.stdout,
        'formatter':'simple'
    },
},
'loggers': {
    'django': {
        'handlers':['console'],
        'propagate': True,
        'level':'INFO',
    }, 
    #'django.request': {
    #    'handlers': ['console'],
    #    'level': 'ERROR',
    #    'propagate': True,
    #},
},
}

Tried both out loggers, active and the one commented out (and many others). Running

python manage.py runserver 0.0.0.0:8080

And yet no strack trace on a 500 error printed my console, just:

[21/Feb/2012 04:21:10] "POST /some/path/function/ HTTP/1.1" 500 105627

What am I doing wrong?

Upvotes: 3

Views: 2954

Answers (3)

Tomáš Plešek
Tomáš Plešek

Reputation: 1492

Took me a while to dig out, but it's because of this:

https://docs.djangoproject.com/en/dev/releases/1.4/#request-exceptions-are-now-always-logged

It's quite confusing and should be highlighted in the logs documentation, which it isn't.

Upvotes: 0

bradley.ayers
bradley.ayers

Reputation: 38382

You need to specify filters:

'loggers': {
    'django': {
        'handlers':['console'],
        'filters': [],             # <-- this line
        'propagate': True,
        'level':'INFO',
    },
},

I don't know why.

Upvotes: 3

avasal
avasal

Reputation: 14854

Logger level has higher priority to handler level, logging.DEBUG has value 10, and logging.INFO has value 20.

'handlers': {
    'console': {
        'level':'DEBUG',
    },
}

'loggers': {
        'level':'INFO',
    }

Hence your logging is always set at INFO level coz of logger priority, and DEBUG output will not be used.

this is what i feels is the issue.

Upvotes: 2

Related Questions