Django Application logging --

12 views
Skip to first unread message

SNJY G

unread,
Jul 22, 2019, 1:28:18 PM7/22/19
to django...@googlegroups.com
Hello Django Experts,
There is Django application which uses LDAP in middleware for user authentication.
I need to record user login and logout time. For that purpose, I think of a basic flow as per following details -
Create new model for logging
Make a function in views.py which will add the login/ logout time and date to a model.
Call the function every time when user login/ logout.
Could someone please suggest better way OR point me to good/relevant article around it.
Thanks,

Andreas Schosser

unread,
Jul 22, 2019, 3:10:00 PM7/22/19
to django...@googlegroups.com
Hi

you can the use Logger class documented in
"https://docs.djangoproject.com/en/2.2/topics/logging/".

Basically the code is something like

import logging
log = logging.getLogger('delhisanjays_app')
log.info.('user logged in')

You can enhance the log message to your needs.

Cheers

Am 22.07.19 um 19:27 schrieb SNJY G:
--
Kurs 10 IT-Consulting www.kurs-10.de
Andreas Schosser a...@kurs-10.de

Baldestraße. 14 Telefon +49 89 41615842-0
80469 München Telefax +49 89 41615842-3

0x85475B6B - 79BB 94F9 8523 0180 E2E5 7A8F 97B7 5BAB 8547 5B6B

signature.asc

SNJY G

unread,
Jul 23, 2019, 12:34:00 PM7/23/19
to django...@googlegroups.com
Hi Andreas,
Thanks for your response. I want to clarify below points --
Above mentioned suggested code should be written in which file ?
How Logging output can be published on admin console ?
Thanks again -- 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7f6d92a7-9ef0-66d7-f07e-51463a99ba3c%40kurs-10.de.
Reply all
Reply to author
Forward
0 new messages