Take control of your log files
Everyone knows about SharePoint’s ULS logs, these are written by the SharePoint tracing service.
To the location set in Central Admin –> Monitoring –> Configure Diagnostic logging
You also have a couple of options to control the number of logs created and /or the amount of space used making SharePoint log space friendly, you should be writing the logs to a non-system drive.
But what about IIS ? In IIS logging can either be on or off, and you can change their location, but that’s about it.
From the IIS console select Logging and open the feature
From here you can set the location for the IIS logs, a location set here will be used for all the sites on the server, and it should be on a non-system drive.
The IIS log location will look something like this, with a number of sub-folders, one for each web application.
the folder names (after the W3SVC) will tally with web site id shown in IIS
each folder will contain a number if log files, normally one created per day.
This folder names will be the same on all your servers as the site ids are replicated, the only problem with this is that the IIS logs never get cleaned-up. To help address this I have written a quick PowerShell script, that will delete log files over 30 days old.
# PS script used to delete IIS logs from sub folders
# set the location to start from
# $location = "D:\logs\iis" use the lines below to read in a location from the command line
$location = $args[0]
if (! $location)
{$location= Read-Host "Enter location to cleanup"}
# get a reference to each file from each subfolder by using the -recursive switch.
foreach ($File in get-childitem $location -Recurse -Include *.log)
# check the lastwrite time and delete if necessary
{if ($File.LastWriteTime -lt (Get-Date).AddDays(-30))
{del $File}}
The location can either be set in the script or read in when you run it, the –Recuse argument causes Get-Child item to walk through nested folders, with the –Include argument putting a filter on log files, with the –30 value specifying how old a file has to be in days to be deleted.
This can wrapped in a simple batch file and called from a weekly scheduled task to keep your IIS files under control.
Follow @NeilKing41-
June 11, 2012 at 12:48SharePoint Daily » Blog Archive » Searching in SharePoint; IE10 Doesn’t Work; The Good & Bad of Windows 8
-
June 11, 2012 at 12:54Searching in SharePoint; IE10 Doesn't Work; The Good & Bad of Windows 8 - SharePoint Daily - Bamboo Nation
-
June 13, 2012 at 12:27Take control of SharePoint your log files - The Microsoft SharePoint Blog