Script for enabling full IIS logging

Published 03 February 08 08:23 AM | jamesbl 

Nothing overly fancy, but useful enough to warrant sharing.  This is something you can use to get your SharePoint farms set up to turn every IIS logging option on.  The good news is each web site in a MOSS farm shares the same web site ID, so it should be pretty easy to batch up:

Option Explicit

On Error Resume Next

 

Dim CmdLineArgs

Dim CurrSite

Dim CurrSiteObj

 

' Obtain all command line args

Set CmdLineArgs = WScript.Arguments.Named

 

' verify args

If (Not CmdLineArgs.Exists("SiteID")) Or _

   (Not CmdLineArgs.Exists("Server")) Then

Wscript.Echo "Error: Invalid number of command line arguments specified."

Wscript.Echo

Wscript.Echo "Usage:  ""cscript FullLogging.vbs /Server:<ServerName> /SiteID:<WebsiteID>"""

Wscript.Quit

End If

 

CurrSiteObj = "IIS://" & CmdLineArgs.Item("Server") & "/w3svc/" & CmdLineArgs.Item("SiteID")

Set CurrSite = GetObject(CurrSiteObj)

If Err.number <> 0 Then

        Wscript.Echo "Error querying IIS provider: " & CurrSiteObj

        Wscript.Echo "Error = " & Err.number & " - " & Err.Description

        WScript.Quit

End If

 

CurrSite.LogExtFileDate             = True

CurrSite.LogExtFileHost             = True

CurrSite.LogExtFileTime             = True

CurrSite.LogExtFileClientIp         = True

CurrSite.LogExtFileUserName         = True

CurrSite.LogExtFileSiteName         = True

CurrSite.LogExtFileComputerName     = True

CurrSite.LogExtFileServerIp         = True

CurrSite.LogExtFileMethod           = True

CurrSite.LogExtFileUriStem          = True

CurrSite.LogExtFileUriQuery         = True

CurrSite.LogExtFileHttpStatus       = True

CurrSite.LogExtFileWin32Status      = True

CurrSite.LogExtFileBytesSent        = True

CurrSite.LogExtFileBytesRecv        = True

CurrSite.LogExtFileTimeTaken        = True

CurrSite.LogExtFileServerPort       = True

CurrSite.LogExtFileUserAgent        = True

CurrSite.LogExtFileCookie           = True

CurrSite.LogExtFileReferer          = True

CurrSite.LogExtFileProtocolVersion  = True

CurrSite.LogExtFileHttpSubStatus    = True

CurrSite.SetInfo

 

wscript.echo "Done!"

Set CurrSite = Nothing

Set CmdLineArgs = Nothing

 

Have fun.

Edit:  If you want to trim the log size down, do not enable the Cookie field, since this can cause the logs to grow rather large over time:

CurrSite.LogExtFileCookie           = False

Thanks, Todd.

Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# SharePoint Link Love: 02-10-2008 part deux at Virtual Generations said on February 10, 2008 10:02 AM:

PingBack from http://www.virtual-generations.com/2008/02/10/sharepoint-link-love-02-10-2008-part-deux/

# SharePoint Products and Technologies - Pointing to Share the Knowledge - Luis Du Solier G. said on October 27, 2008 9:28 PM:

Alguna vez has entrado al IIS Manager MMC y de pronto no ves los Sitios Web ni Applications Pools ni

# SharePoint en Español - Luis Du Solier G. said on October 27, 2008 9:29 PM:

Alguna vez has entrado al IIS Manager MMC y de pronto no ves los Sitios Web ni Applications Pools ni

# Luis Du Solier G. - SharePoint en Español said on October 27, 2008 9:29 PM:

Alguna vez has entrado al IIS Manager MMC y de pronto no ves los Sitios Web ni Applications Pools ni

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required

Search

This Blog

Syndication

Page view tracker