It seems there has got to be a better way to work with log files where
I want to keep 8 days of logs. For instance if I wanted to keep 80
days, this would be a horrible approach. How can I make this more
dynamic and efficient?
Const FTPOutputFile = "output-files.log"
Const FTPOutputFile1 = "output-files-1.log"
Const FTPOutputFile2 = "output-files-2.log"
Const FTPOutputFile3 = "output-files-3.log"
Const FTPOutputFile4 = "output-files-4.log"
Const FTPOutputFile5 = "output-files-5.log"
Const FTPOutputFile6 = "output-files-6.log"
Const FTPOutputFile7 = "output-files-7.log"
Sub Main()
'Do Stuff - gather log information
If a new day
RotateLogFiles()
End if
'Write to log....
End Sub
Sub RotateLogFiles()
'Delete Oldest Log
If objFSO.FileExists(FTPOutputFile7) = True Then
objFSO.DeleteFile(FTPOutputFile7)
End If
'Rotate logs
If objFSO.FileExists(FTPOutputFile6) = True Then
objFSO.MoveFile(FTPOutputFile6, FTPOutputFile7)
End If
If objFSO.FileExists(FTPOutputFile5) = True Then
objFSO.MoveFile(FTPOutputFile5, FTPOutputFile6)
End If
If objFSO.FileExists(FTPOutputFile4) = True Then
objFSO.MoveFile(FTPOutputFile4, FTPOutputFile5)
End If
If objFSO.FileExists(FTPOutputFile3) = True Then
objFSO.MoveFile(FTPOutputFile3, FTPOutputFile4)
End If
If objFSO.FileExists(FTPOutputFile2) = True Then
objFSO.MoveFile(FTPOutputFile2, FTPOutputFile3)
End If
If objFSO.FileExists(FTPOutputFile1) = True Then
objFSO.MoveFile(FTPOutputFile1, FTPOutputFile2)
End If
If objFSO.FileExists(FTPOutputFile) = True Then
objFSO.MoveFile(FTPOutputFile, FTPOutputFile1)
End If
End Sub
Thanks. 1 1557
I would use the date in the file name.
Like OutputFiles_yymmdd.log
If there's no way to search a directory
for all the files written prior to a
specific date, you can always iterate
through the files and parse the name
for the date, and delete them.
Robin S.
-----------------------------
<ba*****@yahoo.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
It seems there has got to be a better way to work with log files where
I want to keep 8 days of logs. For instance if I wanted to keep 80
days, this would be a horrible approach. How can I make this more
dynamic and efficient?
Const FTPOutputFile = "output-files.log"
Const FTPOutputFile1 = "output-files-1.log"
Const FTPOutputFile2 = "output-files-2.log"
Const FTPOutputFile3 = "output-files-3.log"
Const FTPOutputFile4 = "output-files-4.log"
Const FTPOutputFile5 = "output-files-5.log"
Const FTPOutputFile6 = "output-files-6.log"
Const FTPOutputFile7 = "output-files-7.log"
Sub Main()
'Do Stuff - gather log information
If a new day
RotateLogFiles()
End if
'Write to log....
End Sub
Sub RotateLogFiles()
'Delete Oldest Log
If objFSO.FileExists(FTPOutputFile7) = True Then
objFSO.DeleteFile(FTPOutputFile7)
End If
'Rotate logs
If objFSO.FileExists(FTPOutputFile6) = True Then
objFSO.MoveFile(FTPOutputFile6, FTPOutputFile7)
End If
If objFSO.FileExists(FTPOutputFile5) = True Then
objFSO.MoveFile(FTPOutputFile5, FTPOutputFile6)
End If
If objFSO.FileExists(FTPOutputFile4) = True Then
objFSO.MoveFile(FTPOutputFile4, FTPOutputFile5)
End If
If objFSO.FileExists(FTPOutputFile3) = True Then
objFSO.MoveFile(FTPOutputFile3, FTPOutputFile4)
End If
If objFSO.FileExists(FTPOutputFile2) = True Then
objFSO.MoveFile(FTPOutputFile2, FTPOutputFile3)
End If
If objFSO.FileExists(FTPOutputFile1) = True Then
objFSO.MoveFile(FTPOutputFile1, FTPOutputFile2)
End If
If objFSO.FileExists(FTPOutputFile) = True Then
objFSO.MoveFile(FTPOutputFile, FTPOutputFile1)
End If
End Sub
Thanks. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Satish Kumar Chimakurthi |
last post by:
Hi all,
An external solver program is dynamically producing files with different
names 0000001.dat, 0000002.dat, 0000003.dat etc.....at regular intervals.
These files contain all numeric data....
|
by: ischenko |
last post by:
Hi,
I'm trying to find all modules that contain doctests and execute them
(using DocTestSuite). The problem is how to iterate (programmatically)
through the package's modules.
>>> import M...
|
by: John |
last post by:
Hi,
we have the following problem:
in our application v1.0 we have static html pages (+ some javascript).
With a CMS (a Content Management System) some "mortal" people can add
or expand the...
|
by: Arpan |
last post by:
A Form has a select list which lists all the column names of a SQL
Server database table. Users will select one or more than one column
from this select list & after submitting the Form, the...
|
by: Dan Kjaergaard |
last post by:
Hi
I created a program using C#, which iterates files and displays these in a
listview. However I would like to filter the files, so files won't be
displayed if the current user hasn't "read...
|
by: Dan |
last post by:
hi ng,
in my asp.net application, users dynamically can create aspx files and
codebehinds (and other source files).
how can i enforce .net to add these sources to the .dll?
til now, the user...
|
by: wapsiii |
last post by:
I have a form to which I add sets of input controls ie. textbox 1,
dropdownlist 1, textbox 2, dropdownlist 1, textbox 3, dropdownlist 3.
The number of sets vary.
I give them unique IDs the...
|
by: Lie |
last post by:
When you've got a nested loop a StopIteration in the Inner Loop would
break the loop for the outer loop too:
a, b, c = , ,
def looper(a, b, c):
for a_ in a:
for b_ in b:
for c_ in c:...
|
by: ramel |
last post by:
Hi all, I have a problem related to javascript , ajax and jsp.
Please see this url http://xil.co.in/print_screen_2.JPG.
I am working on this form. There are some buttons (like submit ,...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |