On 2/7/22 5:09 PM, Peter J. Holzer wrote:
On 2022-02-06 23:30:41 -0800, blessy carol wrote:
I have this task where I have to create log files to record user
activity whenever they make an entry or view something. Also, I have
to create Database log file whenever someone accessed or manipulated
the data in the database. The code is written python and used django
framework. I've connected django with oracle cloud database. So now I
want to if the basic logging details can be used to store the record
of these activities in the log file in the server.
There are three places where you can do that in a centralized manner:
1. In the database itself. AFAIK Oracle has an audit system, but I've
never used it.
2. At the Django ORM layer. Django has the ability to log all database
queries it makes
3. At the web request level. Your web server (probably) already logs
every request but not necessarily the information you are interested
in. But you could write a piece of middleware for your Django which
extracts log-worthy information and logs that.
The first two options are probably too low-level, and especially the
second is really hard to interpret in an automated manner (which is what
you probably want to do - otherwise why log in the first place?)
So I'd try the third option. But it really depends a lot on the
structure of your application on whether it's feasible to extract all
the data you need at that point. It's possible that you will have to go
through all the views in your app, see what data they are requesting and
altering and craft appropriate log messages for each.
hp
Short of a long lesson on why software developers should always think of
logging/monitoring components to everything they write, I'll just offer
this. It's worth the read and should put you in a good position to
complete your task.
https://www.askpython.com/django/django-logging
If you're after something that you're being paid to do, look into
Splunk! It's a robust package that offers logging and correlation of
data on nearly any level of complication/sophistication your customers need.
Hope this helps.
Regards
Jack
--
https://mail.python.org/mailman/listinfo/python-list