How to Clear Log Files in Bulk older than X days

Follow
    Applies to:
  • SecureAuth Identity Platform
  • Legacy SecureAuth IdP
Deployment model:
  • Hybrid
  • On Premises
  • Version Affected:  All

    Description:  

    How to use Remove-SALogFiles to delete all Audit, Debug and Error text logs over a specific age

     

    Cause:  

    Log files can over time consume a large amount of storage.  Clearing down old log files that are no longer necessary is good practice and will help speed up backups and reduce their size.

     

    Resolution:  

    Download Remove-SALogFiles from here:

    https://secureauth.sharefile.com/d-s670ab8dd455a4a61ae2f6807f836dedf

     

    • After downloading be sure to right click the script, click Properties, then Unblock (if present).
    • The script can be run from any folder on the IdP. 
    • Help on usage and examples can be obtained  by running:
    Remove-SALogFiles.ps1 -help

     

     

    Here's a brief summary of the syntax and some examples:


    Syntax:
    Remove-SALogFiles.ps1
    [-WebconfigFolder <String>] [-All] [-AuditLogs] [-DebugLogs] [-ErrorLogs] [-Confirm]
    [-OlderThan <Int32>] [-WhatIf] [<CommonParameters>]

     

    Examples:

    Remove-SALogFiles -DebugLogs -OlderThan 14
    # Will delete all debug logs older than 14 days.

    Remove-SALogFiles -All -OlderThan 3 -Confirm
    # Will delete all logs older than 3 days without asking for confirmation.

    Remove-SALogFiles -AuditLogs -ErrorLogs -OlderThan 30
    # Will delete Audit and Error logs older than 30 days.

    Remove-SALogFiles -AuditLogs -ErrorLogs -OlderThan 30 -WhatIf
    # Will show which Audit and Error logs older than 30 days would have been deleted.

     

    Note:

    • The -WhatIf switch prevents any files from being deleted even if used in conjunction with the -Confirm switch or answering "Y" to the confirmation.
    • Use the -OlderThan switch to only delete log files older than X days. Defaults to 7 days if omitted. Minimum is 1 day.

     

    Special Considerations:  

    Related Articles:

    https://support.secureauth.com/hc/en-us/articles/360027918591-Log-file-rollover-and-retention-configuration

     

    https://support.secureauth.com/hc/en-us/articles/360041395431-What-logs-files-can-be-cleaned-from-a-SecureAuth-IdP-server-

     

    (Obsolete)

    https://support.secureauth.com/hc/en-us/articles/360019890151-How-to-Clear-Log-Files-in-Bulk

     

     

     

    SecureAuth Knowledge Base Articles provide information based on specific use cases and may not apply to all appliances or configurations. Be advised that these instructions could cause harm to the environment if not followed correctly or if they do not apply to the current use case.

    Customers are responsible for their own due diligence prior to utilizing this information and agree that SecureAuth is not liable for any issues caused by misconfiguration directly or indirectly related to SecureAuth products.

    0 out of 0 found this helpful

    Comments

    0 comments

    Please sign in to leave a comment.