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 -- _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | h...@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!"
signature.asc
Description: PGP signature
-- https://mail.python.org/mailman/listinfo/python-list