Add log file size limitation
The size of the log file should be restricted
Did it grow too large on your system?
Did it grow too large on your system?
If run as a service for a long time, it will generate very large log files; currently, there is no code seen to limit the size/number of log files; we can try optimizing by splitting files and limiting the number of log files;
Makes sense. I usually use a "rolling" log approach similar to below...
I'd probably add another feature to allow keeping log files around longer by compressing old log files using zip. Zipping functionality already exists in the codebase. Because text, we would see very high compression ratios. This would cover scenarios where keeping logs for x amount of time is required for mandatory compliance reasons. This feature would be a "nice to have" compared to the main issue.
// Two settings
int numLogsToKeep 4; // 4 * 5MB log files by default
int maxLogSizeinBytes = 5*1024*1000*1000; // 5 MB default
...
Log.writeMessage(...)
{
...
if (currlogFileSize > maxLogSizeInBytes)
{
reconcileLogFiles();
...
}
}
// etc.