When I run python manage.py shell. Logging works fine, inside my middleware the messages do not get logged to the file. Any ideas why? Code is here asked 25 Aug '11, 17:17 Paul Egges |
Does sending the same data someplace else work? I would add a print to stderr wherever you have logging.debug,
That should send the output to the Apache log and you can verify the loop is executing. You may also want to try printing some of the environment variables with that line to see what the live django stack is using, things like the logging module itself to make sure its importing from the correct path. answered 25 Aug '11, 18:25 johns The last portion of the function sends the same data to the bottom of the browser screen, and it shows up. so........ it is definitely executing. Earlier in the function is an if statement, and either the if or the else should output to the log file.
(25 Aug '11, 21:56)
Paul Egges
I attempted to look for an official answer, since I assume it is some issue with both modules being middleware, but their google code page is down with a 500 error at the moment (http://code.google.com/p/django-logging/wiki/Overview). I did read this in the Django docs, "If a request middleware returns an HttpResponse object, Django won't bother calling any other middleware' "
Does the rest of that function return an HttpResponse?
(25 Aug '11, 22:12)
johns
After calling the log function, the same function returns a response object. The middleware does get called. I put in the code you suggested (to stderr), and data(txt) does end up in the Apache Log file.
(25 Aug '11, 22:23)
Paul Egges
Does that same logging code work from any other place within django, say a regular view? If you use that same print command to print the logging module itself, does it work and show the path to the module? Is this path correct?
(25 Aug '11, 22:37)
johns
The original code with some modification came from another user. I've not tried it in a view. when I bring it up within the python manage.py shell it is the same module that is being loaded when django/wsgi loads the module (checked by print >>sys.stderr, logging.file yielding the same path.
(26 Aug '11, 02:13)
Paul Egges
That is a good plan. I did find some more info, https://docs.djangoproject.com/en/dev/topics/logging/ Notice how in the example code it defines this line,
And than that variable is what is called for future code. Your sample code has this commented out, and is calling the logging module directly. You should try to adjust the code to be more in align with the example.
(26 Aug '11, 02:24)
johns
showing 5 of 6
show 1 more comments
|