IIS Log Archiving

You need to archive your IIS Log often so as not to get your log folder full with HTTP Logs.

I have been searching for some quick implemented solutions for performing this IIS Log archiving task and found some quiet nice discussions and article about it. Here are the links to the different post and forums that talk about a solution to solve this issue:


http://www.iislogs.com/ (Tool to automate maintenance of IIS Log)



On my side i need something with a bit more functionality so, i modified some of the scripts that i could find on the different article related above and came up with a solution that can.

  • Compress each log file found in your websites folder
  • FTP the compressed files on a foreign server ( Keeping historic of your IIS log ) Uses Chillkat Free FTP ActiveX
  • Delete them from your disk afterward

You can launch this process everyday and there will be no log that is older than a specified number of days on your server.

Requirement for this solution to work:

You can download the script here.

See the entire script in the full post.

[sourcecode language=’vb’]Option Explicit

Const ftpSite = “yourftpsite”
Const ftpUsername = “ftpusername”
Const ftpPassword = “ftppassword”
Const bDEBUG = True
Const zipProgram = “C:\gzip\gzip.exe” ‘ Path to your gzip utility
Const zipExtension = “.gz”

Dim objFSO, objFolder, objF, objWS
Dim strYear, strDay, strMonth, strDate
Dim strBaseFTPPath
Dim bFTPUpload

bFTPUpload = False

‘If no arguments passed quit the script
If WScript.Arguments.Count = 0 Then
WScript.Echo “weblogs.vbs startdirectory [ftppath]”
WScript.Quit (1)
End If

‘Check if there is the FTP path Argument sent
If WScript.Arguments.Count > 1 Then
bFTPUpload = True
strBaseFTPPath = wscript.arguments (1)
End If


Leave a Reply

Your email address will not be published. Required fields are marked *