The date settings in the analog report are controlled by the "FROM" and "TO"
directives in the analog.cfg file or in the report specific config file if
there is one.  Analog will then search the log files and process records
within the defined time period.  For example if Analog is pointed at
logfiles generated during December 2001 with a from/to of:

FROM 011210
TO       011216

it generates a report covering the time period Monday 10/12 to Sunday 16/12.
It's possible to store a year's log files in the one directory and just
extract one day but of course Analog will read every log file in the
directory so this could be time consuming.  One point to note.  If you
specify a week but there are only log files covering three days Analog will
produce a report for just those three days and the dates on top of the
report reflect this.  If there is no from/to specified the report period
reflects whatever period the log files cover.

It's possible to automate date changes rather than change the config file
every week.  Simply comment out all instances of from/to directives in the
config file and feed the from/to dates to analog as arguments(most Analog
directives can be overridden on the command line).  Obviously this means you
have to write a script to calculate the required dates.  In my case the
Analog batch jobs run on a Monday producing reports for the previous week.
For example if I run on Monday 07/01/2002 the report covers Mon 31/12/2001
to Sunday 06/01/2002.  It's possible to write this in the  Windows shell but
it's extremely convoluted.  You are better off using Tcl(Tool Control
Language) or Perl.  Here is an example script using Tcl which calculates the
required dates and feeds them to Analog.  Tcl is open source and can be
downloaded from http://sourceforge.net/projects/tclpro

######################################
# Date range for report is Monday to Sunday.
# Job is usually run on Monday but Tcl script will calculate the dates of
the previous Sunday and Monday regardless of what day of the week the report
is run
######################################

set current_time [clock format [clock seconds] -format %k%M%S]

# get day number for current date in the current week.

set current_day [clock format [clock seconds] -format %u]

# get days_ago figure to the start of the current week.

set days_ago [expr {$current_day -1}]

# get the date for the Monday the of current week.

set date_monday [clock format [clock scan "$days_ago day ago" -base [clock
seconds]] -format "%y%m%d"]

# get the date for the previous Sunday.

set to_date [clock format [clock scan "yesterday" -base [clock scan
$date_monday]] -format "%y%m%d"]

# get the date for the previous Monday.

set from_date [clock format [clock scan "7 day ago" -base [clock scan
$date_monday]] -format "%y%m%d"]

set ext .html
set split _
set logformat {+CLOGFORMAT (%s %j "%u" [%d/%M/%Y:%h:%n:%j %j] "%j %r %j" %c
%b "%f" "%B")}

######################################
# Call analog Report using dates.
######################################

exec cmd /c D:\\analog5.1\\analog $logformat    \
                                  $logfile1     \
                                  $logfile2     \
                                  +F$from_date  \
                                  +T$to_date    \
                                  +g$configfile \

+O$outputfile$split$to_date$split$current_time$ext

----- Original Message -----
From: "Aengus" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, January 16, 2002 5:17 AM
Subject: Re: [analog-help] How can I get current weeks log file?


> From: "Jeremy Wadsack" <[EMAIL PROTECTED]>
>
> > Monica Hooge ([EMAIL PROTECTED]):
> >
> > > I have my Windows 2000 server, running IIS 5, creating a weekly log
> > > file (W3SVC1 format) named something like ex020103.log, where 020103
> > > equals YYMMWW.  I want to set the scheduler up to run Analog every
> > > Monday, early a.m. hours and use the prior weeks log file.  What code
> > > line do I enter to tell it to pull last week's log file?
> >
> > You'll have to do some fancy scripting with Windows 2000 command
> > prompt. Look in Start | Help | Contents (tab) | Reference (book) |
> > MS-DOS Commands. You might find other more useful documents from
> > related links.
> >
> > I don't know the specific, but I'm fairly certain there's a way of
> > creating a command prompt that will run Analog on the current week's
> > log files.
>
> You can get the day or the month easily enough, but not the week. For
> example, as far as I can remember, the week rolls over at midnight GMT on
> Saturday, which is 5PM on Saturday evening in Texas. If Monday is the
> first of the month, then the logfile for Sunday could be EXYYMM04,
> EXYYMM05 or EXYYMM06, depending on the circumstances - there really isn't
> any way to calculate that easily.
>
> The simplest way to handle weekly logs is to run Analog immediately after
> the log rolls over, and then call Analog with *.LOG and then move *.log to
> a different folder. You'll get a few extra entries because you might have
> the beginning of the new log file too, but the new log file won't be
> moved, because IIS has it open.
>
> I'd strongly recommend logging on a daily basis, or even on a monthly
> basis, if the logs aren't too long. If you log monthly, you can use
> FROM -00-00-07
> to get the last 7 days, but you still have to deal with month ends.
>
> You can get the day and month within a batch file on NT by using the
> following command:
>
> for /f "tokens=2,3 delims=/ " %%f in ('date /t') do set today=%%f%%g
>
> (You need to double up % signs in a batch file)
>
> Aengus
>
> +------------------------------------------------------------------------
> |  This is the analog-help mailing list. To unsubscribe from this
> |  mailing list, go to
> |    http://lists.isite.net/listgate/analog-help/unsubscribe.html
> |
> |  List archives are available at
> |    http://www.mail-archive.com/[email protected]/
> |    http://lists.isite.net/listgate/analog-help/archives/
> |    http://www.tallylist.com/archives/index.cfm/mlist.7
> +------------------------------------------------------------------------

+------------------------------------------------------------------------
|  This is the analog-help mailing list. To unsubscribe from this
|  mailing list, go to
|    http://lists.isite.net/listgate/analog-help/unsubscribe.html
|
|  List archives are available at
|    http://www.mail-archive.com/[email protected]/
|    http://lists.isite.net/listgate/analog-help/archives/
|    http://www.tallylist.com/archives/index.cfm/mlist.7
+------------------------------------------------------------------------

Reply via email to