vishalanandl177/DRF-API-Logger

How add user_id for logging if user has authorization?

Closed this issue · 4 comments

It would be very convenient to log based on the user ID. But as far as I can see there is no such thing by default, maybe there are thoughts on how to do this?

You can use logger signals for custom logs. There you can filter and log manually.

You can also create a new middleware and extend the DRF API Logger middleware. Set this new middleware in settings.
In this new middleware, you can override your function.

Yes, I understand, thanks, but even so it would be cool to add user_id logging for example as an option.

Usually, we are not supposed to log any user's related information, for example, user auth token, password, or personal information.
If you want to log user_id as well, better send it in headers (value should be encrypted).

I strongly recommend not logging users' related information.