{"id":1231,"date":"2012-09-24T10:42:29","date_gmt":"2012-09-24T10:42:29","guid":{"rendered":"https:\/\/poiseddevelopers.com\/reality-tech\/?p=1231"},"modified":"2024-04-26T12:40:59","modified_gmt":"2024-04-26T12:40:59","slug":"gradually-reducing-the-change-log-for-a-web-application","status":"publish","type":"post","link":"https:\/\/poiseddevelopers.com\/reality-tech\/gradually-reducing-the-change-log-for-a-web-application\/","title":{"rendered":"Gradually reducing the Change Log for a Web Application"},"content":{"rendered":"<h4>Safely reducing the Change Log for a Web Application<\/h4>\n<p>Content Databases by default contain logs of all change events for 60 days. If your Content Databases are under high loads, consider culling these logs.<\/p>\n<p>In general, reducing really large database tables should be done gradually, to prevent Transaction Log failure due to lack of disk space, leading to failures and rollbacks.<\/p>\n<p>There are two related tables that are trimmed through this operation:<br role=\"presentation\" data-uw-rm-sr=\"\" \/>dbo.EventCache<br role=\"presentation\" data-uw-rm-sr=\"\" \/>dbo.EventLog<\/p>\n<p>I do not recommend reducing these to less than 30 days, or disabling them. That is because they seem to be used for two purposes by SharePoint itself. One is for User Alerts, the other is by the search incremental crawl, for detecting content changes.<\/p>\n<p>In the script below, I reduce the log duration one day at a time, and wait a full 10 minutes after triggering the daily Change Log cleanup Timer Job to run.<\/p>\n<p>the internal name of the timer job is \u201cjob-change-log-expiration\u201d. You can get the list of the internal timer job names by using this CmdLet:<\/p>\n<pre lang=\"php\"> \t\r\nGet-SPTimerJob | select name<\/pre>\n<p>Or alternatively, pipe the Web Application into it:<\/p>\n<div><\/div>\n<pre lang=\"php\">get-SPWebApplication http :\/\/SharePoint | Get-SPTimerJob | select name<\/pre>\n<p>Once you get the Timer Job, you can execute it:<\/p>\n<pre lang=\"php\"> $SubTJ = Get-SPTimerJob \"job-change-log-expiration\" -WebApplication $wa\r\n$SubTJ.RunNow()<\/pre>\n<p>Note that the duration of log retention is stored in type \u201cTimespan\u201d. The format in a string is actually \u201cdays.hours.minutes.seconds\u201d, so you can change it to suit your needs.<\/p>\n<div><\/div>\n<pre lang=\"php\">    \r\n$wa=Get-SPWebApplication http :\/\/SharePoint\r\n[TimeSpan]$OneDay=[timespan]\"1.00:00:00\"\r\n[TimeSpan]$TargetDuration=[timespan]\"30.00:00:00\"\r\nwhile ($wa.ChangeLogRetentionPeriod -gt $TargetDuration)\r\n{\r\n    $wa.ChangeLogRetentionPeriod=$wa.ChangeLogRetentionPeriod-$OneDay\r\n    $wa.Update()\r\n    $SubTJ = Get-SPTimerJob \"job-change-log-expiration\" -WebApplication $wa\r\n         $SubTJ.RunNow()\r\n    Write-Host -ForegroundColor DarkGreen \"Change Log Retention Period reduced by a single day to $($wa.ChangeLogRetentionPeriod.Days)\"\r\n    Start-Sleep -s 600\r\n}\r\n \r\nWrite-Host -ForegroundColor DarkRed \"Already reduced the Change Log Retention Period to target\"<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Safely reducing the Change Log for a Web Application Content Databases by default contain logs of all change events for 60 days. If your Content Databases are under high loads, consider culling these logs. In general, reducing really large database tables should be done gradually, to prevent Transaction Log failure due to lack of disk [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":1232,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[26],"tags":[],"class_list":["post-1231","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"_links":{"self":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/1231","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/comments?post=1231"}],"version-history":[{"count":1,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/1231\/revisions"}],"predecessor-version":[{"id":1238,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/1231\/revisions\/1238"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/media\/1232"}],"wp:attachment":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/media?parent=1231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/categories?post=1231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/tags?post=1231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}