microsoft / PowerToys

Windows system utilities to maximize productivity
MIT License
108.75k stars 6.42k forks source link

Logs are never cleaned up #8419

Open enricogior opened 3 years ago

enricogior commented 3 years ago

PowerToys logs are created and never deleted, we should automatically clean up hold logs. We need to verify it for each module:

davidegiacometti commented 3 years ago

What about chose a logging library and use rotation/retention capabilities?

For C# at the moment there are many loggers used:

Settings https://github.com/microsoft/PowerToys/blob/master/src/core/Microsoft.PowerToys.Settings.UI.Library/Utilities/Logger.cs

ColorPicker https://github.com/microsoft/PowerToys/blob/master/src/modules/colorPicker/ColorPickerUI/Helpers/Logger.cs

Run https://github.com/microsoft/PowerToys/blob/master/src/modules/launcher/Wox.Plugin/Logger/Log.cs https://github.com/microsoft/PowerToys/blob/master/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Logger/ProgramLogger.cs

enricogior commented 3 years ago

@davidegiacometti we should definitely use the same logger for all C# projects. Regarding rotation, I'm not a fan of it since we might loose information that we need. I would prefer a logger that logs by day and we should keep the last x days.

davidegiacometti commented 3 years ago

If we want to use a logging library I can work on this for the C# area but I am not sure to finish for 0.29 release. Any preference for the library? nlog, log4net? Would be nice to rely on Microsoft.Extensions.Logging as abstraction even if there is no dependency injection since there are also unit tests.

davidegiacometti commented 3 years ago

@crutkas any thought on logging?

ivan100sic commented 3 years ago

Logs in projects which use spdlog are not erased properly due to a bug in that library. Namely, one function (init_filenames_q_) assumes that logs are always written on consecutive days, which may not be true in case a user doesn't run PowerToys on some day. So perhaps we should try to fix that bug upstream.

enricogior commented 3 years ago

Set as prio-2 for now, but it will be a prio-1 for the following release if not done in 0.37.

crutkas commented 2 years ago

15 days or older

nichols-356 commented 2 years ago

I just cleaned up 75GB of logs from C:\Users\Default\AppData\Local\Microsoft\PowerToys\RunnerLogs. Running PowerToys v0.57.2 on Windows 11 Pro 21H2 (22000.613). Looking forward to a fix!

crutkas commented 2 years ago

I’d love to see why we produced 75gb of logs

gabriel-vanca commented 2 years ago

Same here. Just cleaned 31GB of logs from C:\Users\Default\AppData\Local\Microsoft\PowerToys\RunnerLogs.

Running PowerToys v0.57.2 on Windows Server 2022 21H2 (20348.587)

2022-04-17_23-31-25

crutkas commented 2 years ago

@gabrielv33 can we do a screen share so we can see what is in one of those three Gig files?

@jaimecbernardo fyi

gabriel-vanca commented 2 years ago

Trying to open them without crashing the VM (with somewhat limited RAM) was fun, but here we go: c5 c1 c2 c3

gabriel-vanca commented 2 years ago

I should just add that every single one of my 6 VMs running version 0.57.2 had this problem (logs between 27 GB and 37 GB), while the physical machine running version 0.57.0 did not (logs barely 200 KB).

jaimecbernardo commented 2 years ago

@gabrielv33 @nichols-356 It seems this is a bug of running the first time from installer after an update on some systems. Restarting the computer after updating is the workaround here. Just to understand if this might be the case like in the other reports, are you using admin users with UAC off? This is the issue for the problem you're having: https://github.com/microsoft/PowerToys/issues/17720

jaimecbernardo commented 2 years ago

Although from your logs it seems we can't get the Shell window we use to try to start as non-elevated... We need to fail instead of trying to re-run elevated with the same --dont-elevate flag.

gabriel-vanca commented 2 years ago

@jaimecbernardo Only one of the machines with the problem were running PowerToys as admin. UAC is enabled on all the machines. 2022-04-18_18-47-52

neoOpus commented 2 years ago

These paths (inaccessible without taking ownership or some other hacks) contain gigantic logs,,,

C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Microsoft\PowerToys\RunnerLogs\ C:\Windows\ServiceProfiles\LocalService\AppData\Local\Microsoft\PowerToys\RunnerLogs\

crutkas commented 2 years ago

@neoOpus, logs should be under your user, could there maybe be some type of special scenario you are doing?

Jay-o-Way commented 1 year ago

Is this still an issue with the latest version?

crutkas commented 1 year ago

This should be fixed

crutkas commented 1 year ago

@jaimecbernardo am I wrong in believing this has been fixed?

jaimecbernardo commented 1 year ago

This was fixed for installer logs recently. Not the logs for each utility.

crutkas commented 1 year ago

Didn't https://github.com/microsoft/PowerToys/pull/19875 in 0.62 do this?

Jay-o-Way commented 1 year ago

"Updates" folder is not the same as "Logs"

crutkas commented 1 year ago

@jay-o-way well aware of that, my assumption is this work was done already which is why i'm calling this out and there may have been an expectation that was misunderstood.

Jay-o-Way commented 4 months ago

Ping

gabriel-vanca commented 2 weeks ago

Any update on that purge feature request?