IIS 5 & IIS 6
Compress and archive IIS Logs
Last post Mar 10, 2009 06:09 PM by tomkmvp
Aug 31, 2006 02:18 PM|LINK
Aug 31, 2006 02:54 PM|LINK
Aug 31, 2006 10:50 PM|LINK
Below is a vbs script we use. Not sure if we found it on the net or someone from the team wrote it. Works very well. Does require some sort of commandline based zip program. We use gzip which is availiable free online. Hope this is what you are looking
Const bDEBUG = False
Const zipProgram = "C:\gzip.exe"
Dim objFSO, objFolder, objF, objWS
Dim strYear, strDay, strMonth, strDate
If WScript.Arguments.Count <> 1 Then
WScript.Echo "weblogs.vbs startdirectory"
strDate = Date()
strYear = DatePart ("yyyy", strDate)
strDay = DatePart ("d", strDate)
strMonth = DatePart ("m", strDate)
wscript.echo "Script run on date " & strDate
Wscript.echo "log files more than 5 days old will be zipped."
wscript.echo " "
Set objFSO = CreateObject ("Scripting.FileSystemObject")
Set objWS = CreateObject ("WScript.Shell")
Set objFolder = objFSO.GetFolder (wscript.arguments (0))
For Each objF in objFolder.SubFolders
If bDebug Then wscript.echo "Checking folder " & objF.Path
Set objFSO = Nothing
Set objWS = Nothing
Sub DoDirectory (objFold)
Dim objUserDir, objFile, iDiff
For Each objUserDir in objFold.SubFolders
For Each objFile in objFold.Files
If bDebug Then Wscript.echo "Checking file: " & objFile.Path
If LCase (Right (objFile.Name, 4)) = ".log" and LCase (Left (objFile.Name, 2)) = "ex" Then
Dim strCheckString, strY, strM, strD, strCommand, iResult
strCheckString = Mid (objFile.Name, 3, 6)
strY = "20" & Left (strCheckString, 2)
strM = Mid (strCheckstring, 3, 2)
strD = Right (strCheckString, 2)
iDiff = DateDiff ("d", strM & "/" & strD & "/" & strY, strDate)
If iDiff > 5 Then
strCommand = zipProgram & " " & objFile.Path & ".zip " & objFile.Path
If bDebug Then wscript.echo vbTab & "zip it: " & strCommand
iResult = objWS.Run (strCommand, 0, "true")
If iResult <> 0 Then
If bDebug Then wscript.echo vbTab & "result = " & iResult
If bDebug Then wscript.echo vbTab & "don't zip it"
Sep 01, 2006 05:00 AM|LINK
Shame-less plug - Download IISLogsLite 2.0, this is an application I wrote and provide free of charge. This will zip and/or delete logs and is very configurable plus can save to a remote share. This should meet most of your needs and doesn't require you
to find or purchase any compression programs. It does require the .NET 2.0 framework. One thing I added to this version it will auto-configure by reading the metabase. Hope that helps.
How to save to a remote share
Online help file
Windows Server MVP - IIS
Log archival solution
Install, Configure, Forget
Sep 03, 2006 12:40 PM|LINK
We are currently generating in the region of 1 GB of logs per day for each of our web sites hosted in IIS. We would like to schedule a script that will look for log files older than 24 hours old and then compress each of them into a compressed file format
and then send the compressed file to a network share from where they will be extracted when necessary for analysis purposes.
It is important for us to automate this process.
I hope this makes more sense.
Sep 03, 2006 10:42 PM|LINK
Sep 04, 2006 01:16 AM|LINK
The script I posted previously will also zip files based off of date just change the line If iDiff > 5 Then to the days you want zipped.
The advantage of using a script such as thing is it does not require any additional software to be loaded on your web server. Keeping things simple "clean" and secure are important.
Sep 04, 2006 04:06 AM|LINK
I don't want to sound like I'm pushing my EXE over the script, I almost hesitated in posting a link to it. I didn't want to sound like I was self-promoting my program. It comes down to whatever is easier for the person to support in their environment.
I agree having a vbs script along with a compression file either gzip or winzip with the command line add-on works great, although winzip is 29.95 I think. My program is written using the .NET 2.0 framework and if this framework is loaded on the server, you
can install my program on a separate machine then 'xcopy' without having to install on the server. It's whatever the person wants to-do. I've handled logs with scripts and that is what gave me the idea to develop it in the first place. Many administrators,
including me use VBS scripts over 3rd party apps because they have control of the source code. Either way these are just a couple of ways for him to achieve what he wants.
PS: Thanks for posting your VBS script. You should publish on a blog or write a short article on your script and how you use it. I'm sure there are lots of people would appreciate that. If you want, I can publish on my blog along with giving you the proper
credit. If you do publish, let me know and I'll link to the article. Thanks again!
Sep 04, 2006 02:52 PM|LINK
I don't mean to be a pain, but the script seems to be the better option for me as I will be deploying this across many servers in a load balanced environment which do not currently run .Net Framework 2.0. I have copied the script to notepad and saved it
as a .vbs file, but I am not quite sure what to do next. If I run the script I get a message saying:
I am not very experienced at script writing so will need a bit of guidance.
Sep 04, 2006 03:38 PM|LINK