{"id":2077,"date":"2016-03-08T12:08:33","date_gmt":"2016-03-08T11:08:33","guid":{"rendered":"http:\/\/blogs.msdn.microsoft.com\/lavanack\/?p=42"},"modified":"2022-05-30T13:50:32","modified_gmt":"2022-05-30T11:50:32","slug":"iis-logs-maintenance-scripts","status":"publish","type":"post","link":"https:\/\/laurentvanacker.com\/index.php\/2016\/03\/08\/iis-logs-maintenance-scripts\/","title":{"rendered":"Scripts de compression et suppression des logs IIS avec des outils natifs \/ Compression and removal scripts for IIS logs with built-in tools"},"content":{"rendered":"<div id=\"fr-FR\"><a href=\"#en-US\">English version<\/a><\/div>\n<p>[MAJ 23\/06\/2016] IIS n&rsquo;inclut pas de script ou de m\u00e9canisme de rotation de ses logs et par exp\u00e9rience je sais que peu de clients impl\u00e9mentent un tel m\u00e9canisme. Je vais vous montrer au travers de cet article qu&rsquo;il est tr\u00e8s facile et en peu de lignes de mettre en place un tel m\u00e9canisme. Pour cela je m&rsquo;appuierai sur deux scripts n&rsquo;utilisant que des ressources pr\u00e9sentes nativement sous Windows:<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/lavanack\/laurentvanacker.com\/blob\/master\/Command%20Prompt\/IIS\/Log\/Cleanup\/CompressIISLogFilesOlderThan10Days.cmd\" target=\"_blank\" rel=\"noopener noreferrer\"><b>CompressIISLogFilesOlderThan10Days.cmd<\/b><\/a> : Comme son nom l&rsquo;indique ce script compressera tous les fichiers *.log dont la date de modification est sup\u00e9rieure \u00e0 <strong>10<\/strong> jours.<\/li>\n<li><a href=\"https:\/\/github.com\/lavanack\/laurentvanacker.com\/blob\/master\/Command%20Prompt\/IIS\/Log\/Cleanup\/RemoveIISLogFilesOlderThan30Days.cmd\" target=\"_blank\" rel=\"noopener noreferrer\"><b>RemoveIISLogFilesOlderThan30Days.cmd<\/b><\/a> : Comme son nom l&rsquo;indique ce script supprimera tous les fichiers dont la date de modification est sup\u00e9rieure \u00e0 <strong>30<\/strong> jours.<\/li>\n<\/ul>\n<p>Et vous vous dites en PowerShell \u00e7a doit pouvoir se faire &#8230; la r\u00e9ponse est <a href=\"https:\/\/laurentvanacker.com\/index.php\/2016\/06\/02\/iis-logs-maintenance-scripts-powershell\/\" target=\"_blank\" rel=\"noopener noreferrer\">l\u00e0<\/a><\/p>\n<hr \/>\n<div id=\"en-US\"><a href=\"#fr-FR\">Version fran\u00e7aise<\/a><\/div>\n<p>[Updated 06\/23\/2016] IIS doesn&rsquo;t include scripts or mechanism for the IIS logs rotation and I know by par experience that only few customer implement a such mechanism. I&rsquo;ll show you through this article that it is very easy and in few lines to set up such a mechanism. For this I will build on two scripts using only these Windows built-in resources:<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/lavanack\/laurentvanacker.com\/blob\/master\/Command%20Prompt\/IIS\/Log\/Cleanup\/CompressIISLogFilesOlderThan10Days.cmd\" target=\"_blank\" rel=\"noopener noreferrer\"><b>CompressIISLogFilesOlderThan10Days.cmd<\/b><\/a>: As its name suggests this script will compress all *.log files whose modification time is greater than <strong>10<\/strong> days.<\/li>\n<li><a href=\"https:\/\/github.com\/lavanack\/laurentvanacker.com\/blob\/master\/Command%20Prompt\/IIS\/Log\/Cleanup\/RemoveIISLogFilesOlderThan30Days.cmd\" target=\"_blank\" rel=\"noopener noreferrer\"><b>RemoveIISLogFilesOlderThan30Days.cmd<\/b><\/a>: As its name suggests this script will remove all files whose modification time is greater than <strong>30<\/strong> days.<\/li>\n<\/ul>\n<p>And you say to yourself in PowerShell it should be easy &#8230; the answer is <a href=\"https:\/\/laurentvanacker.com\/index.php\/2016\/06\/02\/iis-logs-maintenance-scripts-powershell\/\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.<\/p>\n<p>Laurent<\/p>\n","protected":false},"excerpt":{"rendered":"<p>English version [MAJ 23\/06\/2016] IIS n&rsquo;inclut pas de script ou de m\u00e9canisme de rotation de ses logs et par exp\u00e9rience je sais que peu de [&#8230;]<\/p>\n","protected":false},"author":2,"featured_media":2465,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,18],"tags":[25],"class_list":["post-2077","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-iis","category-ms-dos","tag-iis"],"_links":{"self":[{"href":"https:\/\/laurentvanacker.com\/index.php\/wp-json\/wp\/v2\/posts\/2077","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/laurentvanacker.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/laurentvanacker.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/laurentvanacker.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/laurentvanacker.com\/index.php\/wp-json\/wp\/v2\/comments?post=2077"}],"version-history":[{"count":8,"href":"https:\/\/laurentvanacker.com\/index.php\/wp-json\/wp\/v2\/posts\/2077\/revisions"}],"predecessor-version":[{"id":2968,"href":"https:\/\/laurentvanacker.com\/index.php\/wp-json\/wp\/v2\/posts\/2077\/revisions\/2968"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/laurentvanacker.com\/index.php\/wp-json\/wp\/v2\/media\/2465"}],"wp:attachment":[{"href":"https:\/\/laurentvanacker.com\/index.php\/wp-json\/wp\/v2\/media?parent=2077"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/laurentvanacker.com\/index.php\/wp-json\/wp\/v2\/categories?post=2077"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/laurentvanacker.com\/index.php\/wp-json\/wp\/v2\/tags?post=2077"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}