Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Not applicable

Log File Creation via MACRO

I want to create a log file for my qvw documents. The log file will contain the reload start and end time of document.

For getting these times i have made vStartTime=time(now() ), vEndTime=time(now()) and put set these variables before load of first table and end of last table.

The document path and the date of reload. I want this information to be appended into a txt file or maybe a csv file. I want to keep history of the reload start and end time in that txt file. The latest updates in the values will have to be appended to txt file. I managed to fetch date of reload, start and end time of execution and document path into 4 variables. How should i get these information appended into a txt or csv file ?

Please Help Me

Tags (2)
5 Replies

Log File Creation via MACRO

"Why re-invent the wheel?"

The qvw document script log gives you all times and information you need about the reload of a document, from beginning to end - including every script statement and iterations. Consume that log files with Qlikview (or another program of choice) and do a Max() and Min() on the timestamps, and you've got your data.

Activate the Script Log in Qlikview Desktop > Settings > Document Properties > Generate Logfile. The file is going to be named the same as the qvw, plus an additional ".log" and wind up just next to the reloaded (source) document.

Not applicable

Log File Creation via MACRO


You can generate the logfile directly,

Setting ------->Document Properties---------->tick on generate logfile checkbox

Thanks and Regards,

Not applicable

Log File Creation via MACRO

Yes i have done that. But the problem is that i have a several batch files which reload some qvw files in an order at specific times. eg in the night...I want he execution start and end times of all the qvws listed in the batch files daily. the log generated qvw execution contains much data not needed by me.

now if i do this i will get seperate log files for every qvw. I want a consolidated log of every qvw reloaded in a batch

any suggessions how can i accompolish this ?

Not applicable

Log File Creation via MACRO

one way i thought is to make an inline table with all time and directory variable as fields. and then store as txt. but it stores only the time of the latest reload of the qvw. it dosent append data into the txt file.

Not applicable

Log File Creation via MACRO

Tell me if what I've done is corerct.

I have created 8 variables: 4 are initialised at the start of the main script, 4 at the end of script. They are -

/*********** QVW Statistics VARIABLES ***********/
let vConnectString=if(ConnectString()<>NULL(),'Y','N');
let vStartTime=time(now());
let vDocumentPath=documentpath();
let vDocumentName=documentname();
/*********** QVW Statistics VARIABLES ***********/
let vEndTime=time(now());
let vExecutionDate=today();
let vDuration=interval(vEndTime-vStartTime,'HH:MMSmiley FrustratedS');
let vLastModifiedOn = filetime(documentname());

Then stored them in a table with some error variables:

load * inline
StartTime, EndTime, Duration, ExecutionDate, Path, Name, Datasource, LastModified, ErrorMode, ScriptErrorCount, ScriptErrorList
$(vStartTime),$(vEndTime),$(vDuration),$(vExecutionDate),$(vDocumentPath), $(vDocumentName), $(vConnectString), $(vLastModifiedOn), $(ErrorMode), $(ScriptErrorCount), $(ScriptErrorList)

Now at the post reload event of the qvw application i've written a macro

Sub ExportV
on error resume next
set Obj=ActiveDocument.GetSheetObject("TB01")
Obj.Export "D:\Rajeev\Documents\LOGS\LOG.txt",",",,true
end sub

Which appends the table data into a text file. This code can be written in every qvd at the specified place and it will log the information to the common LOG.txt file. A demo LOG.txt is attached. This LOG.txt can be called in a new qvw application and analysed.

I wanted a common log filing of all my qvw applications. I achieved a little functionality by this implementation.

How is it ?[View:http://community.qlik.com/cfs-file.ashx/__key/CommunityServer.Discussions.Components.Files/11/6180.LOG.txt:550:0]

Community Browser