Re: Access request body in the django.request logger

2016-11-07 Thread Justin Wilson
Sorry, I had those reversed. It works find WITH uWSGI, and fails with the Django dev server. On Monday, November 7, 2016 at 2:48:14 PM UTC-7, Justin Wilson wrote: > > Stumbled across this post while trying to solve the same issue > *(we've had this issue since 1.10 release, but have kept with

Re: Access request body in the django.request logger

2016-11-07 Thread Justin Wilson
Stumbled across this post while trying to solve the same issue *(we've had this issue since 1.10 release, but have kept with 1.9 due to this issue).*We're only getting this with Django 1.10+ when running behind uWSGI. The issue goes away if we just run the Django dev server. On Thursday,

Re: Access request body in the django.request logger

2016-09-15 Thread Ben Whale
I should add that this difference in behavior occurs because the handlers array in the Logger class is different in the two cases. Specifically in the line "for hdlr in c.handlers:" in the file /logging/__init__.py the variable c.handlers is empty ([]) in the first case and is a

Re: Access request body in the django.request logger

2016-09-15 Thread Ben Whale
Thanks for a link to the blob, that is very helpful. You might be right, but the more I look at this the more I think it is a bug. The logging message is generated in django/utils/log.py in the ServerFormatter format() method. If the logging setting is LOGGING = {

Re: Access request body in the django.request logger

2016-09-15 Thread Tim Graham
The logging is coming from here: https://github.com/django/django/blob/43c471e81c27542e4dc392dfa2310c5a52db35d9/django/core/servers/basehttp.py#L103 where self.request is indeed a "socketobject" I'm not sure if the WSGIRequest object is available at that point, so possibly this just needs a

Re: Access request body in the django.request logger

2016-09-15 Thread Ben Whale
Well my last reply was preemptery. A minimal working example can be produced via the following commands. First navigate to a suitable directory then, # virtualenv venv --no-site-packages # source venv/bin/activate # pip install django # django-admin startproject mwe # vim mwe/mwe/settings.y and

Re: Access request body in the django.request logger

2016-09-15 Thread Ben Whale
Thanks for the reply Tim Some testing seems to indicate that it is an issue with django-rest-framework. When I contact the web server using urls managed by django rest the issues occurs, when I do the same via url managed by vanilla django the request variable in the context object is an

Re: Access request body in the django.request logger

2016-09-15 Thread Tim Graham
If true, it does seem like a bug. Could you provide a test for Django's test suite or a sample project to reproduce it? On Thursday, September 15, 2016 at 6:53:55 AM UTC-4, Ben Whale wrote: > > Hi > > What I'd like to do is log the request body whenever the django.request > logger logs

Access request body in the django.request logger

2016-09-15 Thread Ben Whale
Hi What I'd like to do is log the request body whenever the django.request logger logs something. I had assumed that the extra context referred to as request in https://docs.djangoproject.com/en/1.10/topics/logging/#django-request was something like an HTTPRequest object. It is, however, an