Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to configure filter 'request_id': 'module' object has no attribute 'middleware #68

Closed
hyamy opened this issue Jun 7, 2022 · 4 comments

Comments

@hyamy
Copy link

hyamy commented Jun 7, 2022

logging filters 'request_id' is app.middleware.RequestIDFilter

@j4mie
Copy link
Member

j4mie commented Jun 7, 2022

Hi,

Can you share your logging config? The filters section should look like this:

    'filters': {
        'request_id': {
            '()': 'log_request_id.filters.RequestIDFilter'
        }
    },

So 'log_request_id.filters.RequestIDFilter', not 'app.middleware.RequestIDFilter'. But maybe I'm misunderstanding the question...

@hyamy
Copy link
Author

hyamy commented Jun 7, 2022

'filters': {
'request_id': {
'()': 'app.middleware.RequestIDFilter'
}
}
my RequestIDFilter is in app/middleware.py, my logging config is in app/utils/logger.py

@j4mie
Copy link
Member

j4mie commented Jun 7, 2022

The RequestIDFilter is part of django-log-request-id so you shouldn't need to put it in your own code (app/middlware.py) - unless you're using a custom one? Also you might be getting confused between the log filter and the middleware - both are needed but they are separate things. Putting a log filter in a file called middleware.py feels a little odd.

Also your logging config should really be in your settings.py - see https://docs.djangoproject.com/en/4.0/topics/logging/

@hyamy
Copy link
Author

hyamy commented Jun 7, 2022

Thank you, I can run through according to your directory structure

@hyamy hyamy closed this as completed Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants