rutgermons
asked on
vbs script extract data from logs within last 24 hours
folks
how can I extract specific data from other logs into another log file but only after a specific timestamplis met i.e. i want to extract the values
"system#notboundexception" Or "Successfully connected" from log 1 and log 2 but only if they are logged within the last 24 hours from now
log 1
[14/03/14 16:04:51:985 GMT xxxxxxxxxxxx eeeeeeeeeeeeeee
system#notboundexception
[15/03/14 10:04:51:985 GMT xxxxxxxxxxxx eeeeeeeeeeeeeee
system#notboundexception
log 1
[12/03/14 16:24:51:985 GMT xxxxxxxxxxxx eeeeeeeeeeeeeee
system#notboundexception
[15/03/14 10:04:51:985 GMT xxxxxxxxxxxx eeeeeeeeeeeeeee
Successfully connected
output.log should only show the log entries from either log 1 /2 on over the last 24 hours (being today)
how can I achieve this?
Below is my code to extract the values from the logs , I need help in assuring only todays records are extracted only
Dim objFSO
Dim objFile
Dim objOut
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
Const intForReading = 1
'create output file
strOutputName = "output.txt"
Set objOut = objFSO.GetFolder(strFolder ).CreateTe xtFile(str OutputName , True)
'for each file in directory
For Each objFile In objFSO.GetFolder(strFolder ).Files
'if its a log file
If Right(LCase(objFile.Name), 4) = ".log" Then
'open log file
Set objLogFile = objFSO.OpenTextFile(objFil e.Path, intForReading, False)
'loop thorugh log file
Do While Not objLogFile.AtEndOfStream
strData = Replace(objLogFile.ReadLin e, ",", "")
'replace(var,",","")
If InStr(strData, "system#notboundexception" ) Or InStr(strData, "Successfully connected") Then objOut.WriteLine strData & ", " & objFile.Name & ", " & Date & ", " & Time & ""
Loop
objLogFile.Close
Set objLogFile = Nothing
End If
Next
objOut.Close
all help will do
how can I extract specific data from other logs into another log file but only after a specific timestamplis met i.e. i want to extract the values
"system#notboundexception"
log 1
[14/03/14 16:04:51:985 GMT xxxxxxxxxxxx eeeeeeeeeeeeeee
system#notboundexception
[15/03/14 10:04:51:985 GMT xxxxxxxxxxxx eeeeeeeeeeeeeee
system#notboundexception
log 1
[12/03/14 16:24:51:985 GMT xxxxxxxxxxxx eeeeeeeeeeeeeee
system#notboundexception
[15/03/14 10:04:51:985 GMT xxxxxxxxxxxx eeeeeeeeeeeeeee
Successfully connected
output.log should only show the log entries from either log 1 /2 on over the last 24 hours (being today)
how can I achieve this?
Below is my code to extract the values from the logs , I need help in assuring only todays records are extracted only
Dim objFSO
Dim objFile
Dim objOut
Set objFSO = CreateObject("Scripting.Fi
Const intForReading = 1
'create output file
strOutputName = "output.txt"
Set objOut = objFSO.GetFolder(strFolder
'for each file in directory
For Each objFile In objFSO.GetFolder(strFolder
'if its a log file
If Right(LCase(objFile.Name),
'open log file
Set objLogFile = objFSO.OpenTextFile(objFil
'loop thorugh log file
Do While Not objLogFile.AtEndOfStream
strData = Replace(objLogFile.ReadLin
'replace(var,",","")
If InStr(strData, "system#notboundexception"
Loop
objLogFile.Close
Set objLogFile = Nothing
End If
Next
objOut.Close
all help will do
ASKER
Kimputer
Could you show me where this exactly fits in the code?
thanks in advance!
Could you show me where this exactly fits in the code?
thanks in advance!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If InStr(strData, "system#notboundexception"
add an extra test for date as in:
if (cdate(mid(strData,2,17)) > DateAdd("d", -1, Now)) then