Share via


Script for enabling full IIS logging

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.

Comments

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

  • Anonymous
    October 27, 2008
    Alguna vez has entrado al IIS Manager MMC y de pronto no ves los Sitios Web ni Applications Pools ni

  • Anonymous
    October 27, 2008
    Alguna vez has entrado al IIS Manager MMC y de pronto no ves los Sitios Web ni Applications Pools ni

  • Anonymous
    October 27, 2008
    Alguna vez has entrado al IIS Manager MMC y de pronto no ves los Sitios Web ni Applications Pools ni