Page MenuHomePhabricator

MITK log file has no size limit
Closed, ResolvedPublic

Description

Currently the mitk log file has no size limit. While this is not usually noticeable on development computers, where the config directory changes regularily it increased to 11 GB on a computer dedicated to tracking for several weeks.

Either it should have a fixed file size limit, beyond it can not increase or be deleted each application start.

Event Timeline

Another approach could be to create a new log file on each application start (with a unique name) and have a configuration mechanism that e.g. log files older than a week are deleted at start-up and / or all old log files are deleted such that the total size taken by all log files does not exceed a certain number.

I talked to Markus about this problem and he proposed a rotating logfile mechanism. This means that there is a separate log file for every run and the log files of the last X runs are stored on the harddisk.

E.g. Logfile1 - Logfile10. Whenever there is a new run of the application all logfiles are renamed to Logfile -1 which means the oldest is deleted. Logfile10 is the new one.

Markus stated that such mechanisms are also used by operating systems.

We will implement this fix next bug squashing.

New remote branch pushed: bug-16274-SizeLimitLogFiles

branch was tested under linux and windows and works fine on both systems

A few comments:

The patch rotates the log files, but it actually does not solve the original problem. In theory, each of these log files could still grow over several GB or more (depending on the application).

Implementation remarks:

  • The method HandleRollingLogFile does not do any error handling if files were successfully renamed
  • The method HandleRollingLogFile also does two things: Rotating the log file names, and calling SetLogFile() with the -0 filename.

I would like to have these two actions separated. Rename the method to

std::string RotateLogFiles(const std::string& prefixPath)

(use std::string instead of const char* - I know Markus says otherwise!) and it should just rotate the files and create the new empty -0 file (just open and close a std::ofstream object). If that does not fail, return the file path. If it fails, handle the error (and return an empty string).

The user should then set the returned file path as the new log file himself by using the SetLogFile method.

I don't think that the size of the log file of one single MITK run is the "original problem". This would mean to have MITK running for many days with a lot of console output without any restart. In my opinion this is more a theoretical problem.

Solving this problem would be much more complex than the current solution. However, the current solution should solve the problem which was reported inside this bug.

The other issues, e.g. renaming and splitting the methods are not a big problem, we can do this in the next bug squashing.

Current release is finished. Reseting target milestone...

New remote branch pushed: bug-16274-MITKLogFileSizeLimitBasedOnMasterJan2014

I addressed most of the issues mentioned above:

  • The main method was renamed to RotateLogFiles(const std::string& prefixPath)
  • The method was further spitted to one part which renames the log files and one part which sets the logfile name to the new free name.
  • Added error handling to all of the methods. E.g., if there are file access problems the errors will now be handled.

All the changes were committed to a new integration branch:

bug-16274-MITKLogFileSizeLimitBasedOnMasterJan2014

The problem with the size of a single log file was not addressed because of the reasons argued in my last comment. I would propose to add a new bug/feature request to handle this bug if it's necessary.

Adding a core change request again.

[bcdcc2]: Merge branch 'bug-16274-MITKLogFileSizeLimitBasedOnMasterJan2014'

Merged commits:

2014-02-12 16:05:52 Alfred Franz [cc2b6e]
added a new test case which tests if the temporary files are actually unique


2014-02-12 14:57:34 Alfred Franz [05b21f]
added error handling to the rotating logfile methods.


2014-02-12 14:13:59 Alfred Franz [75a6aa]
separated method into two submethods


2014-02-12 13:39:28 Alfred Franz [7dcbf3]
renamed method


2014-02-12 13:33:16 Alfred Franz [d08d02]
Merge branch 'bug-16274-SizeLimitLogFiles' into bug-16274-MITKLogFileSizeLimitBasedOnMasterJan2014


2013-10-30 15:57:15 Alfred Franz [7f3cbe]
added new method for handling of a rolling log file system. Old log files are deleted now, so the size is limited.

[bca21c]: Merge branch 'bug-16274-MITKLogFileSizeLimitBasedOnMasterJan2014'

Merged commits:

2014-02-12 16:50:32 Alfred Franz [5d6d28]
COMP(#16274): now using c string instead of std::string

[13e404]: Merge branch 'bug-16274-MITKLogFileSizeLimitBasedOnMasterJan2014'

Merged commits:

2014-02-12 17:04:59 Alfred Franz [c711d9]
COMP(#16274): removed reference because of linux compile problems

[7d6780]: Merge branch 'bug-16274-MITKLogFileSizeLimitBasedOnMasterJan2014'

Merged commits:

2014-02-12 17:24:24 Alfred Franz [52970f]
COMP(#16274): made method public to make code compiling under linux...

[ff3db3]: Merge branch 'bug-16274-MITKLogFileSizeLimitBasedOnMasterJan2014'

Merged commits:

2014-02-12 17:47:19 Alfred Franz [eb9df9]
COMP(#16274): made parameter const