Skip to content

vscode-powershell logs rotation #5079

Closed
@o-l-a-v

Description

@o-l-a-v

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.

Summary

Would be great if vscode-powershell could rotate its own log files, as in delete logs older than X days. Maybe a sane default would be 30 days, with a overridable setting in settings.json? Or only keep X latest logs no matter date and time, maybe 20?

PS > Get-ChildItem -Directory -Path ('{0}\Code\User\globalStorage\ms-vscode.powershell\logs' -f $env:APPDATA) |
    Sort-Object -Property 'LastWriteTime' |
    Select-Object -First 1 -Last 1

    Directory: C:\Users\olav.birkeland\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\logs

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----          28.09.2022    15:02                1664370174-9c0cd76c-5603-4542-9722-a56b3e73645a1664370154962
d----          01.11.2024    10:40                1730454055-b57d49db-d6c5-49b0-8239-a5cd952e2a651730454050247

PS >

Ref: https://github.com/PowerShell/vscode-powershell/blob/main/docs/troubleshooting.md#logs

Proposed Design

Get-ChildItem -Directory -Path ('{0}\Code\User\globalStorage\ms-vscode.powershell\logs' -f $env:APPDATA) |
    Sort-Object -Property 'LastWriteTime' -Descending |
    Select-Object -Skip 30 |
    ForEach-Object -Process {
        $null = Remove-Item -Path $_.'FullName' -Recurse
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions