Loading TOC...

alert:make-log-action

alert:make-log-action() as element(alert:action)

Summary

Create a standard logging action named "log". Rules that reference this action must provide an <alert:directory/> element that specifies where the log file should be created. The inserted document will have a random long integer ID and its filename will be ID.xml within the specified directory.

Rules that reference this action may also provide options with an <alert:permissions> element containing a series of <sec:permission> elements and/or an <alert:collections> element containing <alert:collection> elements that specify the permissions and collections for the log document. This information is simply passed through to xdmp:document-insert. An example of the rule's options is as follows:
<alert:options>
  <alert:directory>/some/directory</alert:directory>
  <alert:permissions>
    <sec:permission>
      <sec:capability>read</sec:capability>
      <sec:role-id>129382323</sec:role-id>
    </sec:permission>
  </alert:permissions>
  <alert:collections>
    <alert:collection>http://acme.com/alert-log</alert:collection>
  </alert:collections>
</alert:options>

The log document has the following structure:

<alert:log>
  <alert:log-id>82388423</alert:log-id>
  <alert:config-uri>http://acme.com/alert/message-board</alert:config-uri>
  <alert:rule-id>12352</alert:rule-id>
  <alert:user-id>8271938239</alert:user-id>
  <alert:document-uri>/the/URI/of/the/matching/document</alert:document-uri>
  <alert:timestamp>2008-05-31T08:20:00-08:00</alert:timestamp> 
</alert:log>

The log document insertion will be performed as the user who created 
the rule, and the user must have permission to create documents in any 
collections they specify. The log-id is a random number chosen by 
the action.

Example

  xquery version "1.0-ml";
  import module namespace alert = "http://marklogic.com/xdmp/alert" 
		  at "/MarkLogic/alert.xqy";

  alert:action-insert(alert:make-log-action())
  

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.