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)
    {
    ++$count
    $fileName = "{0}{1}.{2}" -f ($rootName, $count, $ext)
    }
    }

    $reader.Close()

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

  • #767572
    Hi,

    If you want to split up your large file into smaller pieces then refer below link this might be helpful to you, "gallery.technet.microsoft.com/scriptcenter/PowerShell-Split-large-log-6f2c4da0"

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

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


  • Sign In to post your comments