The Problem

One problem we have with the apps and the synchronizers is that we don’t have controlled logging in order to evaluate the performance. This is an issue that surfaces quite often when investigating various issues (examples-go-here). We can add some data points towards solving such issues by adding calls into our scripts using the QlikView Components library ; a very interesting and useful library with subroutines utilities that we partially use already (eg for creating a Calendar Table).

Logging calls

Logging is a means of tracking events that happen when some software runs. The software’s developer adds logging calls to their code to indicate that certain events have occurred. An event is described by a descriptive message which can optionally contain variable data (i.e. data that is potentially different for each occurrence of the event).

First things first

To start logging we need to make the library available into our scripts.

/* Include the qvc.qvs file at the beginning of your script. */
$(Must_Include=path-to-qvc\qvc_runtime\qvc.qvs);

Then in order to suppress interaction with error windows (ie press OK in each error) set ErrorMode to silence.

SET ErrorMode=0;

Just for reference setting it to 1 results into the normal behaviour you expect in each error (press OK to continue execution) and 2 results to break the execution on the first error.

A Log

It is straightforward to add a logging message in the body of the script like this

CALL Qvc.Log('Starting script');

Add attributes to logs

Events also have an importance which the developer ascribes to the event; the importance can also be called the level or severity. We can use three levels of logging

| Level | When it’s used | |———|——————–| | INFO | Confirmation that things are working as expected. | | WARNING | An indication that something unexpected happened, or indicative of some problem in the near future (e.g. ‘disk space low’). The software is still working as expected. | | ERROR | Due to a more serious problem, the software has not been able to perform some function. | If omitted, default is Qvc.Log.v.Level.INFO.

QlikView Error Variables

Things we can log in our messages are based on the following variables

ScriptError

ScriptErrorList

ScriptErrorDetails

ScriptErrorCount

Sometimes you want logging output to contain contextual information in addition to the parameters passed to the logging call (probably using a bit of concatenation to get more comprehensible messages).

Log once or keep a history?

By default the logging will retain records for 1 day. If we need more days of log to keep in log file we can configure it.

SET Qvc.Log.v.KeepDays = 10 /* I will keep 10 days worth of logs */

Store logging externally

Except from storing the log messages in the application we can direct the output to a log file.

Summary

When starting a new application use a lot of logging and as your script gets formulated and ironed out remove a lot of INFO recording to the bare minimum. Also, keep in mind that the logging is not capable of catching all errors occurring in the execution unless we have a Qvc.LogError call in place.

Appendix

Qlikview’s standard logging

Qlikview can generate its own log natively. Navigate to Settings > Document properties > General and select Generate log-file. Opt-in for the timestamp in log-file as well.

You can add custom messages in this file using the TRACE function, e.g

TRACE 'Load Landings Details Table' ;

Error codes

QlikView operates on 13 error codes. Traditionally 0 is reserved for No error.