ART Logging

Introduction

ART logging is a server side tool to capture traffic between Orbeon and eXist. It supports the following functions:

  • Turning logging on and off
  • Capture all requests made to eXist
  • Inspect those requests
  • Excute those requests server-side against eXist
  • Edit the requests with eXide, and execute the changed request.

Capturing browser-server traffic (F12) with Orbeon/eXist development is not always usefull. F12 typically captures calls between Orbeon client side code en Orbeon XForms server, and this does not reflect the actual XForms code written, making this hard to debug. Also it's often not obvious which calls are executed in XForms, especially when code uses stuff like event watchers and triggers. ART Logging allows the developer to trace and inspect all calls from Orbeon to eXist.

ART Logging can be found at: [server]:[8877]/apps/artlog/modules/logging.xquery

Enabling ART Logging

ART Logging is enabled in a package by inserting a controller.

xquery version "3.0";

import module namespace artlog = "http://art-decor.org/ns/artlog" at "../artlog/modules/artlog.xqm";

let $log  := if ($artlog:logOn) then artlog:logRequest('xis') else ()
return
    <ignore xmlns="http://exist.sourceforge.net/NS/exist">
        <cache-control cache="no"/>
    </ignore>

If there already is a controller, put the existing code after the 'return' statement. Put the appname where it says 'xis'. This logs all requests to your app. Execute some application logic through the browser. Open ART Logging, if already open Refresh, and inspect.

  • SHOW shows the logged request in the Left hand pane.
  • GET/POST executes the request again, and shows URL, status and response in the right hand pane.

POSTdata

POSTdata provides a special challenge. ART Logging cannot log it with request:get-data(), since this effectively eats the POSTdata, which is now empty on the request object. This means that the actual eXist code further downstream which should handle the POSTdata no longer works.

Somewehere in your code there will be a line like:

let $data := request:get-data()/*

Place

let $log := if ($artlog:logOn) then artlog:logPostData($data, 'lab') else ()

after this line to capture the POSTdata. Don't forget to include the artlog module:

import module namespace artlog = "http://art-decor.org/ns/artlog" at "../../artlog/modules/artlog.xqm";

Execute the logic which calls this code in ART. The ART Logging now has captured the POSTdata, as well as the POST call. Click 'SHOW' for the POSTdata, which now opens in the left hand pane. Click 'POST' on the row below the POSTdata. If the left-hand pane contains POSTdata, executing the request will send this POSTdata in the POST request. If the left-hand pane does not contain POSTdata, the GET or POST is executed with just the query params and no POSTdata.

Logging other stuff

It's possible to log any node with:

let $log := if ($artlog:logOn) then artlog:logPostData($myNode, 'xis', 'myName') else ()

The node will be logged, and the name will show up in the ART Logging, so you can inspect it.

Turn on or off?

ART Logging discards all data older than 30 minutes. This makes it pretty safe to have it open all the time in your dev environment: your log dir won't fill up, and you can inspect what's going on all the time. In a production environment, when off, users other than admin cannot write to the artlog-data collection. When turning it on, they can, since it may be necessary to capture requests for guest users. However, ART Logging does not allow anything which a script or a utility such as Postman doesn't offer, so there are no security risks other than temporary write access to artlog-data.