When to record logs in database?

Asked

Viewed 1,331 times

3

I participate in a team that is developing an application using Zend framework 2 and Mysql database. We need to develop a logging feature of the actions performed by users in order to enable audits by the application itself. We are a new team and this is the first time we will do something like this. I’m afraid to record the logs in bank and the table will get very large.

So my question: when it is indicated to save logs in the database?

  • 4

    Three years later, and there is a comment: logging into DB is practical, but it is one more layer to give problem. If the data is too important, log as "primitively" as possible (system log, file) and transfer to DB later, so if DB fails, it did not lose the original record.

2 answers

4


(the question is somewhat broad and the answers will depend on the experience of each).

If you have the opportunity, log in the comic book:

  • Makes it easier to manipulate data;
  • It is simple to clean and manage (automatic backups et al);
  • Guaranteed durability by BD;
  • You can easily access your BD network without having to share folders;

Note:

In case you have an application that will be on the client’s side, then I would say it is preferable to log both ways. The general logs in the BD but have logs in file also (for higher levels (Warning, Error, Fatal)) so that in case of problems, the client can send the files without knowing how to use the BD.

2

Your question will probably be closed because it is based on opinions, but I believe I can answer something within the scope of the OS.

Be afraid yes, but not because the table gets big, but optimises it in the best way. A good example of optimization is to use indexes.

The problem is not being great, if so facebook would be in trouble, but the performance of your database/ application.

The logs are not frequently consulted (in most cases) and yes eventually and will be quite missed when, for example, something does not run as planned.

If your fear is to leave the user locked when generating a log, do this in the background in the language you are using and leave the user free to continue using the application.

  • I would complement this answer by saying that you should record as many logs as necessary to satisfy your level of paranoia by control. Maniac developers register EVERYTHING, but everything: login, logou, registration, profile editing... If you don’t need so much, log in the key points. Using the @Leonardopatricio example, record in the exclusion of an item, in the edition of an item (discount price...), in the use of a discount coupon at checkout time...

  • @Brunoaugusto that is already an opinion and I tried not to take to this side.

  • 3

    That’s why I commented instead of answering ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.