Always check the timestamp when reading logs

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the dumb-mistakes-and-gotchas category.

Last Updated: 2024-11-23

The date was Nov 6. A friend's server had suddenly crashed. I knew little about its code but ssh-ed in anyway and called tail -f on the first log file I could find. It showed something like this:

==> storage/logs/laravel.log <==
[2019-10-28 17:34:23] laravel.ERROR: Undefined class constant 'MYSQL_ATTR_LOCAL_INFILE' 
 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): 
 Undefined class constant 'MYSQL_ATTR_LOCAL_INFILE' at /root/project_s/config/database.php:56)
[stacktrace]
#0 /root/project_s/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php(72): require()
#1 /root/steu

Seeing the constant MYSQL_ATTR_LOCAL_INFILE and recognizing it as a recurrence of a previous error, I jumped into action to repair what I thought was the bug.

In fact I had been mistaken — this particular error had already been resolved — on Oct 28. If I had paid attention to the timestamp in the logs (2019-10-28), I would have seen that this bug was a week old and could not possibly be the cause of today's issue.

The cause of my confusion - aside from not paying attention to the timestamp - was that there were multiple log files. If I had tailed them all, I would have seen the error affecting the current code.

Lesson

When debugging, even if the most recent entry in tail -f seems to suggest a particular error, always pay attention to the actual timestamps.