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|BTandy|LINK
Aug 31, 2006 02:54 PM|tomkmvp|LINK
Aug 31, 2006 10:50 PM|kryan762|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|steve schofield|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|BTandy|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|steve schofield|LINK
Sep 04, 2006 01:16 AM|kryan762|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|steve schofield|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|BTandy|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|steve schofield|LINK
Oct 13, 2006 01:50 PM|Londonsa|LINK
I am also looking to zip my IIS files and send them to another server for storage.I agree ,I would rather use a script,no offense but I used the app and didnt get any joy there and the support email never got back.
But any way the script seems okay but I would like to know ,does the script assume the log files are in the default place in Windows.I have told IIS to say my logs files on another directory ?Where in the script can I change that path ?
Oct 13, 2006 04:42 PM|steve schofield|LINK
If you are referring to the script posted. All you need to do is specify the start folder in your command line argument. There shouldn't be a need to update the script unless the gzip.exe location is different than specified in the script. Here is the
portion of the script that read the VBS arguments and kicks off the zipping process. Sorry to hear you didn't like IISLogsLite. The script below should meet your needs. Good luck.
Mar 10, 2009 04:40 PM|santosh.kuamr|LINK
I downloaded gzip.exe from gzip.org and it is not working with VBS provided in this thread. Am i missing something? is this gzip.exe has the same alogorithm which IIS using?
Mar 10, 2009 05:46 PM|tomkmvp|LINK
Do you realize this thread is 2 1/2 years old?
What does "not working" mean? What happens?
Mar 10, 2009 05:53 PM|santosh.kuamr|LINK
does 2 1/2 matters as far as logic goes? And moreover this link is given as reply to my other thread, which i posted yesterday. So, i felt it is appropriate to write on this thread.
Basically i want to know, gzip.exe, which is discussed here is the same exe which i downloaded? I have downloaded from gzip.org but it does not allow me to zip file names more than 8 characters long.
Mar 10, 2009 06:09 PM|tomkmvp|LINK
The person who posted that script hasn't posted here since September 2006 so there's not a very good chance that he'll respond. Obviously his logic worked for him.
It probably is the same but there's no way to know unless he responds, but it really shouldn't matter what zip exe you use. As far as help with a particular zip program's capabilities and command line reference, you'd probably be best served following up
with the developer of that exe ...