4

Is there any way to clean-up logs for Sitecore 9.3 Identity Server?

I searched for logging configuration but didn't find any. I want to update configuration so that it automatically deletes logs older than 10 days.

2

Identity Server uses Serilog (https://github.com/serilog/serilog) for writing logs and a single file sink is configured by default.

Which retains 31 files (for one month) by default. If you want to retain only 10 days log then pass retainedFileCountLimit argument with value set to 10 in <IS Siteroot>\sitecorehost.xml as shown below

enter image description here

References -

  1. https://doc.sitecore.com/developers/91/sitecore-experience-manager/en/logging.html
  2. https://github.com/serilog/serilog-sinks-file#limits
3
3

If you want to do at Sitecore level only then you can add entry for IdentityServer log folder in <agent type="Sitecore.Tasks.CleanupAgent" of CM website but make sure you give delete access to IIS AppPool user e.g. - IIS AppPool\CMSiteAppPoolUser

<remove folder="C:\inetpub\wwwroot\sc93identityserver.dev.local\logs" pattern="*.*" maxAge="10.00:00:00"/>

enter image description here

1

I think that it should be done not on the Sitecore level.

I do the similar thing by scheduled PowerShell script. For your case this Powershell script should do the work:

$old = 10
$folder = 'your path'
Get-ChildItem $folder | Where-Object {-not $_.PSIsContainer -and $now.Subtract($_.CreationTime).Days -gt $old } | ForEach-Object {Remove-Item $_.FullName -Confirm:$false -Force -Recurse}

Then you need to add execution of this script to Windows scheduler if you work with on-premise hosting or use WebJobs if you use Azure PaaS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.