Link to home
Start Free TrialLog in
Avatar of johnhardy
johnhardyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Log Files

I have a dedicated server at Fasthosts with a few web domains. Windows Server 2003

Each domain automatically collects log files of each visit.

I wondered if it is possible to dispense with these log files, they get very large and I do not use them.
Can anyone advise me on this please?

Thank you

John
Avatar of vaibhavjaiman
vaibhavjaiman
Flag of India image

Hello,

You can rotate the logs file ,Here is an example of the code under the vb script.

************************************************************************************************
Option Explicit

Dim intDaysOld, strObjTopFolderPath, strLogFIleSuffix, ObjFS, ObjTopFolder
Dim ObjDomainFolder, ObjW3SvcFolder, ObjSubFolder, ObjLogFile, ObjFile,ObjDomainsubFolder,ObjDomainlogsFolder

intDaysOld   = 3
strObjTopFolderPath = "C:\HostingSpaces"
strLogFIleSuffix = ".log"

Set ObjFS = CreateObject("Scripting.FileSystemObject")
Set ObjTopFolder = ObjFS.GetFolder(strObjTopFolderPath)

For Each ObjDomainsubFolder in ObjTopFolder.SubFolders  

For Each ObjDomainFolder in ObjDomainsubFolder.SubFolders

For Each ObjDomainlogsFolder in ObjDomainFolder.SubFolders

 For Each ObjW3SvcFolder in ObjDomainlogsFolder.SubFolders



  Set ObjSubFolder = ObjFS.GetFolder(ObjW3SvcFolder)

   For each ObjLogFile in ObjSubFolder.files

    Set ObjFile = ObjFS.GetFile(ObjLogFile)
    If datediff("d",ObjFile.DateLastModified,Date()) > intDaysOld and lcase(right(ObjLogFile,4))=strLogFIleSuffix then
     '*****************************************************
     'DON'T UNCOMMENT THIS UNTIL YOU KNOW IT WORKS PROPERLY!!!
     'WScript.Echo("Will delete " & ObjSubFolder.name & "\" & ObjFile.name)
     ObjFile.Delete
     '*****************************************************
    End If
    Set ObjFile = nothing
   Next
  Set ObjSubFolder = nothing
 Next
Next
 Next
Next

Set ObjTopFolder = nothing
Set ObjFS = nothing
************************************************************************************************

http://forum.dotnetpanel.com/forums/t/2991.aspx
http://forum.dotnetpanel.com/forums/p/1239/21163.aspx
http://forums.webhostautomation.com/showthread.php?t=18656
ASKER CERTIFIED SOLUTION
Avatar of Leon Fester
Leon Fester
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of johnhardy

ASKER

Many thanks for the solution, regret I did not understand the previous solution.

Thanks

John
What i mean is that you can remove the logs files based on the log file date history.

Suppose if you are placing your website contents under the path

c:\domains\yourdomains-name\log\your logs files here

You can simply use the above script to delete the files older than 3 days.

Hope it might help you ,
Thanks vaibhavjaiman
I understand now more fully but regret that you solution is too advanced for me.

Sorry

Regards

John
No Problem,

Hope it will help you in future.