The $cfg->log_file option only writes the last output

Bug #1938347 reported by Robert Lyon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Confirmed
Wishlist
Unassigned

Bug Description

There is a configuration option in Mahara where you can specify a file to save logging to. This is useful if you are wanting to debug something but do not have access to the apache/nginx error logs.

The problem with it though is on every write to the file it deletes the existing data because we open the file with:
  $LOGFILE_FH = fopen($logfilename, 'wb');

What would be more useful is if the log file remembered existing lines of logging for better diagnosis, eg appending new lines to end of file.

We would need to do it in such a way that we didn't end up with one giant log file that keeps growing until the server is full.

My idea is this:

If you have $cfg->log_file = $cfg->dataroot . '/logs/custom.log';

On writing to the file check the number of lines existing in the custom.log file and once it gets to be more that a certain number, say 10000 lines, it copies that file to custom.log.old and starts a new custom.log file to write to

That way you only end up with max 2 files of max approx 20000 lines and it will be faster than trying to append new lines to base of custom.log while removing lines from start of custom.log

Robert Lyon (robertl-9)
description: updated
Changed in mahara:
importance: Undecided → Wishlist
Changed in mahara:
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.