Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7845643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:18:19+00:00 2026-06-02T17:18:19+00:00

Am on django 1.3., python 2.6 In the django docs here https://docs.djangoproject.com/en/1.3/topics/logging/#django-request it says

  • 0

Am on django 1.3., python 2.6

In the django docs here
https://docs.djangoproject.com/en/1.3/topics/logging/#django-request
it says that messages have the following extra context: status and request.
How do you get these to show up in the debug file? i tried in my logging config something like:

'formatters': {        
        'simple_debug': {
            'format': '[%(asctime)s] %(levelname)s %(module)s %(message)s %(request.user)s',        
        }
    },

but that causes the overall logging to fail (i.e. no logging output happens)


EDIT:
So immediately after submitting the question i came across this:
http://groups.google.com/group/django-users/browse_thread/thread/af682beb1e4af7f6/ace3338348e92a21

can someone help explain/elaborate on

All the quote from the docs really means is that all the places inside
of django where django.request is used, the request is explicitly
passed in as part of extra.

where is request explicitly passed in as part of extra to?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:18:20+00:00Added an answer on June 2, 2026 at 5:18 pm

    You can’t use request.user in the format string, as %-formatting doesn’t handle that. You could use a format string such as

    '[%(asctime)s] %(levelname)s %(module)s %(message)s %(user)s'
    

    and, in your logging call, use something like

    logger.debug('My message with %s', 'args', extra={'user': request.user})
    

    The extra dict is merged into the logging event record, which ends up with a user attribute, and this then gets picked up through the format string and appears in the log.

    If using the django.request logger, the status_code and the request will be passed in the extra dict by Django. If you need the request.user, you’ll probably need to add a logging.Filter which does something like:

    class RequestUserFilter(logging.Filter):
        def filter(self, record):
            record.user = record.request.user
            return True
    

    so that you can show the user in the formatted output.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As I am working through https://docs.djangoproject.com/en/1.4/topics/db/models/ , in django, I have started a new
I have read the Django documentation (For reference, https://docs.djangoproject.com/en/1.3/intro/tutorial01/ ), but I'm still having
I'm doing this Django tutorial https://docs.djangoproject.com/en/dev/intro/tutorial01/ and was_ published _today isn't working. Thanks for
I was going through this tutorial in order to learn how Django works: https://docs.djangoproject.com/en/dev/intro/tutorial01/
Manual example: http://docs.djangoproject.com/en/1.0/topics/forms/formsets/#formset-validation (I'm using Django 1.0.3 to run on Google App Engine) Code:
I'm trying to implement signals from Django ( http://docs.djangoproject.com/en/dev/topics/signals/ ), or its concept in
I am having difficulties debugging a django/python application that requires a public key to
A python/django beginner's question: I have a datetime object (drive_date), a time object (start_time)
I have built Web sites with Python/Django and desktop applications with Objective-C/Cocoa so programming
as described in http://developers.facebook.com/docs/api#publishing i want to make a post request to update a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.