Im building a very small website which has an admin and public area

what i want to know is

your prefence when it comes to reporting or logging

ie. when admin or user insert, update, delete, from and to the database

changes will be written to either a database or a text file

which one do you prefer?

which one is better?

why?

thanks!

Dani AI

Generated

raised whether CRUD change reporting should be a DB record or a text file; pointed out the value of a configurable logger. The right choice depends on goals: how often audit data needs to be queried, required throughput, retention and compliance rules, and whether logs must be tamper-evident or easily shipped off-server.

Database audit table — good when records must be queried, joined and reported (for example: who changed which object, when, and what the old/new values were). Anticipate table growth, add appropriate indexes, and plan archival. File-based logs — lower write overhead and simple append semantics, easier to integrate with external log shippers, but poor for ad hoc SQL-style queries unless logs are preprocessed. Hybrid is common: structured logs (JSON) written to files and sent to a centralized store, while key audit events are inserted into the DB.

Practical implementation notes: store append-only audit rows with timestamp, actor id, action, object type/id, IP/session, and a payload of changed data (JSON). Ensure audit entries are created inside the same transaction or use DB triggers so an action and its audit stay consistent. Redact or hash any sensitive fields and apply a documented retention policy with regular archiving. Use a logging abstraction or library so handlers can switch between file, DB, or remote sinks without changing business code.

Relevant resources: OWASP Logging Cheat Sheet for security and data-handling guidance, and MySQL triggers docs for trigger-based audit techniques. For a small admin/public site, a simple DB audit table is often the most practical; scale or multi-server needs make structured file logs plus a central pipeline preferable.

Recommended Answers

All 2 Replies

If you use a tool like log4php for example, you define in your configuration file where the logging has to go. So if it some point you no longer want to log to file, you just change the configuration.

Personally I prefer database, because it makes it easier to filter to specific events.

makes sense! what about the others? whats your preference?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.