You must Sign In to post a response.
  • Category: Sharepoint

    Query SharePoint Log files

    I ran a powershell query for get the farm merged log file for a day. But unfortunately the file size is huge and it couldnt open in a uls log viewer. The original log files were deleted and i have only newly created file thru powershell, can i query this new file and split the file into 2 half`s.? if so what is the query?
  • #767549
    I have not tried but you can query on log file (txt file) to split them in small files, see below snippet and see how it works for you

    $reader = new-object System.IO.StreamReader("C:\Exceptions.log")
    $count = 1
    $fileName = "{0}{1}.{2}" -f ($rootName, $count, $ext)
    while(($line = $reader.ReadLine()) -ne $null)
    Add-Content -path $fileName -value $line
    if((Get-ChildItem -path $fileName).Length -ge $upperBound)
    $fileName = "{0}{1}.{2}" -f ($rootName, $count, $ext)


    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #767572

    If you want to split up your large file into smaller pieces then refer below link this might be helpful to you, ""

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • Sign In to post your comments