SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
VBS and the Log file

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
VBS and the Log file
Author Message
Rick Ireland



Joined: 30 Oct 2000
Posts: 44

Post VBS and the Log file Reply with quote

Hi -

Can I write messages to the trace log file from VBS?

Tue Dec 21, 2004 11:46 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7970

Post Re: VBS and the Log file Reply with quote

Which file exactly do you want to write to? I ask this becasue some log files can be updated directly while some other are alwasy in use and they can be updated only by writing to process console.

: Hi -

: Can I write messages to the trace log file from VBS?

Tue Dec 21, 2004 11:58 am View user's profile Send private message
Rick Ireland



Joined: 30 Oct 2000
Posts: 44

Post Re: VBS and the Log file Reply with quote

: Which file exactly do you want to write to? I ask this becasue some log files
: can be updated directly while some other are alwasy in use and they can be
: updated only by writing to process console.

At the end of all my JAL scripts, I capture a copy
of the script.log file and store it off to a side
folder that is accessable to the support engineers;
we also archive these for security purposes, as they
document the individual steps taken to complete
each task.

Tue Dec 21, 2004 1:32 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7970

Post Re: VBS and the Log file Reply with quote

You already have these copies saved in the Performance Data directory. There should be a full history of your script runs since you enabled the tracing option. Log file names have format [job id].log. While script.log could be a mix of several jobs running at the same time, these log files have clear output for each job.
VBS currently doesn't write trace files because the entire job script is sent to VBS engine as a single piece of text and 24x7 doesn't get any notifications about line execution.

To implement the tracing in VBS you can add you own function calls to write some data to a log file. Here is an example of how to do that:

This is your VBS job
Sub Main()
WriteTrace(True, "Starting 1 ....")
... 1. you do something here
WriteTrace(False, "Starting 2 ....")
... 2. you do something here
WriteTrace(False, "Done")
End sub

Sub WriteTrace(add_header, text)
Dim fso, log
Set Fso = CreateObject("Scripting.FileSystemObject")
Set log = Fso.OpenTextFile("@V"24x7_home"\Performance Data\@V"job_id".log", 8, 1)
If add_header Then
log.WriteLine("*******************")
log.WriteLine(Date() & " " & Now())
log.WriteLine("*******************")
End If
log.WriteLine(text)
Set log = nothing
Set fso = nothing
End Sub

: At the end of all my JAL scripts, I capture a copy
: of the script.log file and store it off to a side
: folder that is accessable to the support engineers;
: we also archive these for security purposes, as they
: document the individual steps taken to complete
: each task.

Tue Dec 21, 2004 1:59 pm View user's profile Send private message
Rick Ireland



Joined: 30 Oct 2000
Posts: 44

Post Re: VBS and the Log file Reply with quote

: You already have these copies saved in the Performance Data directory. There
: should be a full history of your script runs since you enabled the tracing
: option. Log file names have format [job id].log. While script.log could be
: a mix of several jobs running at the same time, these log files have clear
: output for each job.
: VBS currently doesn't write trace files because the entire job script is sent
: to VBS engine as a single piece of text and 24x7 doesn't get any
: notifications about line execution.

: To implement the tracing in VBS you can add you own function calls to write
: some data to a log file. Here is an example of how to do that: This is
: your VBS job
: Sub Main()
: WriteTrace(True, "Starting 1 ....")
: ... 1. you do something here
: WriteTrace(False, "Starting 2 ....")
: ... 2. you do something here
: WriteTrace(False, "Done")
: End sub

: Sub WriteTrace(add_header, text)
: Dim fso, log
: Set Fso = CreateObject("Scripting.FileSystemObject")
: Set log = Fso.OpenTextFile("@V"24x7_home"\Performance
: Data\@V"job_id".log", 8, 1)
: If add_header Then
: log.WriteLine("*******************")
: log.WriteLine(Date() & " " & Now())
: log.WriteLine("*******************")
: End If
: log.WriteLine(text)
: Set log = nothing
: Set fso = nothing
: End Sub

...okay, that makes sense - of course you'd pass the script to
the MS engine.

Thanks for the code, too; I used it in key stages I wanted to
isolate, and that saved me from re-writing 30-some scripts.
You guys are alright - I think I'll keep you.

Thu Dec 23, 2004 11:17 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7970

Post Re: VBS and the Log file Reply with quote

You are welcome.

BTW, in the next version 24x7 will add support for VBS functions in the Script Library. Then you will not need to copy&paste the same "utility" functions code to multiple jobs.

: ...okay, that makes sense - of course you'd pass the script to
: the MS engine.

: Thanks for the code, too; I used it in key stages I wanted to
: isolate, and that saved me from re-writing 30-some scripts.
: You guys are alright - I think I'll keep you.

Thu Dec 23, 2004 11:47 am View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.