New-SPLogFile PowerShell - create new SharePoint log file


Posted on : Fri, 25th Sep 15 06:45 pm UTC
2314 votes

Analyzing SharePoint logs has never been an easy task. Though there are tools available for better reading of logs, huge log files can always give you some pain and extra efforts.

What to do when the log file is very huge in size. Is there a way to create a new fresh log file whenever required ? The answer is Yes !

New-SPLogFile PowerShell cmdlet

Whenever you feel the current log file is getting large (even few MB's), use the New-SPLogFile command to generate a new log file quickly.
Just open SharePoint Management Shell as administrator (right click - run as administrator) and type below command

Syntax

New-SPLogFile [-AssignmentCollection <SPAssignmentCollection>]

where AssignmentCollection is an optional parameter which manages objects for the purpose of proper disposal.

Example

New-SPLogFile

So simple, yet very handy command.

Code2care's mission is to share varied knowledge in technical and non-technical areas gathered during day-to-day learnings and development activities so that our visitors can leverage this portal to find solutions to their queries without re-inventing the wheel. Technical posts include Learnings, Tutorials, Video Tutorials, Code Snippets, Tips-n-tricks.

Follow us : Facebook - Twitter - Google +