Why Database Logging Is Superior To File Logging

https://about.me/jakesajao
3 min readApr 12, 2020

This article is meant for beginners in software programming. Senior programming could as well glean on ideas that could further improve their arts and skills, as well.

Definition

What is logging? A log is a record of what has happened in a software program. In other words, a log is simply writing what is being done in detail by a computer program, according to Nadine Giasson St-Amand. It is logging that captures what goes behind-the-scene in deployed applications today.

Only a handful of developers implement logging features in hundredth of apps rolled out daily in Africa. It is a pity.

As you know, we have two major logging processes: database logging and file logging. There is event logging as well in windows, that is outside the scope of this write-up.

For so many years, I was not a fan of logging not until I changed job. All my life I always stick to server logging ­­­– apache tomcat.

After being introduced to File Logging, I could not have enough, thinking File Logging is all I needed to track changes in applications.

Everything is illimitable until the limit is exceeded, my Physics teacher taught me well.

Issue

There was a project that defied all my perceptions I had of File Logging. It is truly limited. Nothing is one-size-fit-all indeed. I implemented a network API to a third-party platform that uploaded records every five seconds outside my local environment. The issue is that it spikes every two hours partly because the destination is not well designed to handle too much workload coming from my end.

I leveraged on Log4j framework to do the logging actually since it is a Java project. My file log spans several files, each is configured to have 10,000KB before the next one breaks and spurns another cycle of file. Due to the huge network failure my app reports in the log file, my log could not capture the point where the failure occurs because of the huge growth.

This becomes head-ache for me. I painstakingly open log files after log file, all to no avail in a bid to track spot where the failure happened — Filtering is practically impossible.

Database Logging

Until I read more. I found out that database logging is the key! Rather than file logging, database logging is better designed to handle filtering and spot the exact point where spiking begins.

Advantage of database logging:

  • In application migration, database logging is well suited because you do not have to perform data log migration since the log resides in the database repository. Unlike file logging that you have to worry about relocating the text file and space to achieve this.
  • As log file grows, filtering becomes tedious and herculean task to perform. So file log is not an option in the long-term. You would not want to commit the same poor foresight I made, right? In fact, database logging offers you control over the performance of your application.
  • Since database logging possesses an index feature that offers the speed of data retrieval.
  • You have better control of performance.

Finally, I’m persuaded that the foregoing has added new skills to your arsenal as a better programmer. Thanks for following me take you on this journey. Kindly like and share the post. See you next time.

--

--