{"id":2680,"date":"2024-03-05T14:26:52","date_gmt":"2024-03-05T12:26:52","guid":{"rendered":"https:\/\/itsimple.info\/?p=2680"},"modified":"2024-03-05T14:27:01","modified_gmt":"2024-03-05T12:27:01","slug":"how-to-split-very-large-log-file-to-smaller-size-files","status":"publish","type":"post","link":"https:\/\/itsimple.info\/?p=2680","title":{"rendered":"How to Split Very Large Log File To Smaller size files"},"content":{"rendered":"\n<p>Log files can get very large in size making them very hard to work with. There are many ways to split log files, with applications or split command, but I found this Powershell script that did this task and give you some option in the process :<\/p>\n\n\n\n<pre class=\"wp-block-code has-pale-cyan-blue-background-color has-background\"><code>$SourceFile = \"C:\\path\\to\\large.log\"\n$MaxSize = 100MB\n$Prefix = \"smalllog\"\n$Counter = 1\n\n$Reader = New-Object System.IO.StreamReader($SourceFile)\n$OutputFile = New-Object System.IO.FileStream(\"$Prefix$Counter.log\", 'Create', 'Write', 'ReadWrite')\n$Buffer = New-Object byte&#91;] 1024\n\ndo {\n    $BytesRead = $Reader.BaseStream.Read($Buffer, 0, $Buffer.Length)\n    if ($BytesRead -gt 0) {\n        $OutputFile.Write($Buffer, 0, $BytesRead)\n        if ($OutputFile.Length -gt $MaxSize) {\n            $OutputFile.Close()\n            $Counter++\n            $OutputFile = New-Object System.IO.FileStream(\"$Prefix$Counter.log\", 'Create', 'Write', 'ReadWrite')\n        }\n    }\n} while ($BytesRead -gt 0)\n\n$Reader.Close()\n$OutputFile.Close()<\/code><\/pre>\n\n\n\n<p> <\/p>\n\n\n\n\n\n<figure class=\"wp-block-pullquote has-vivid-green-cyan-color has-text-color has-link-color has-medium-font-size wp-elements-64fedf5822c3d1154d583473adba9c92\"><blockquote><p>Good Luck<\/p><\/blockquote><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Log files can get very large in size making them very hard to work with. There are many ways to split log files, with applications or split command, but I found this Powershell script that did this task and give you some option in the process : Good Luck<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14],"tags":[],"class_list":["post-2680","post","type-post","status-publish","format-standard","hentry","category-tutorials","category-windows"],"_links":{"self":[{"href":"https:\/\/itsimple.info\/index.php?rest_route=\/wp\/v2\/posts\/2680","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itsimple.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itsimple.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itsimple.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itsimple.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2680"}],"version-history":[{"count":0,"href":"https:\/\/itsimple.info\/index.php?rest_route=\/wp\/v2\/posts\/2680\/revisions"}],"wp:attachment":[{"href":"https:\/\/itsimple.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2680"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itsimple.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2680"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itsimple.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2680"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}