Octopus Tools | Maintenance of log files



Whenever an Octopus tool, such as MailIntegration, is executed, a log file is created. By default the file is created in the Octopus folder of the computer that ran the program. 

Which means in some cases, especially with MailIntegration that hundreds of log files could be created in one day. It is therefore necessary to manage / archive these files so that they do not take up too much space.

File Management

It is recommended to check each of the Octopus administration tools used to see if there is any need to manage log files.

Octopus tools are:

Manage With a Windows Task

We recommend keeping 30 days of log history to assist the investigation in case of a problem.

To delete the files in a Windows task, use the DOS ForFiles command, for example:

:: Create a temporary variable environment

:: The number of days of history to keep
   SET OctopusLogCleaner.Delay=30

:: The name of the application for which to destroy the logs
   SET OctopusLogCleaner.Tool=MailIntegration

:: The folder in which to purge the files
   SET OctopusLogCleaner.Path=%LocalAppData%\Octopus

:: Search all files matching the search mask in the folder being older
:: than the retention period to delete them
   FORFILES.exe ^ 
     /M %OctopusLogCleaner.Tool%*.log ^
     /D -%OctopusLogCleaner.Delay% ^
     /P %OctopusLogCleaner.Path% ^
     /C "cmd.exe /c DEL @path"

:: Destroy the temporary variable environment

Automate With /PurgeLogs

Old log files can automatically be erased by adding the /PurgeLogs parameter to the Octopus tools command line.

The parameter is used to determine the number of days of log files that you want to keep.

The value of the parameter is in days.

The parameter is used as follows:

  • /PurgeLogs:0
    • Keeps the file that will have been generated when launching the Octopus tool, if any.
  • /PurgeLogs:1
    • Keeps the files of the current day.
  • /PurgeLogs:2
    • Keeps the files of the current day, plus another. 

  • Etc. 

There is no limit to the number of days, but the value must be a whole value, if you use /PurgeLogs:2.5, the parameter will be completely ignored by the system.

Example: If today's date is 2019-08-15 and you run an Octopus tool with the /PurgeLogs:2 parameter, then the log files that are older than 2019-08-13 will be deleted.


Help us improve our articles

Help us improve our articles