Getting Started

Retrieving Audit Log

Updated: October 1, 2024

Goal

Retrieve a document's audit log to gather its history. All actions made on a document are stored in this audit log for security review purpose.

Prerequisites

Procedure

  1. Create a file called getDocumentAudit.js with the following content.

    #!/usr/bin/env node
    const Nuxeo = require('nuxeo');
    const nuxeo = new Nuxeo({
        auth: {
            method: 'basic',
            username: 'Administrator',
            password: 'Administrator'
        }
    });
    let docToFetch = '/default-domain/workspaces/North America/awesome-tech/skynet-ai-maintenance';
    nuxeo.repository()
        .fetch(docToFetch)
        .then(doc => {
            return doc.fetchAudit();
        })
        .then(audit => {
            console.log(`Document's audit log is as follows:`);
            console.log(audit);
        })
        .catch(error => {
            console.log(`Apologies, an error occurred while retrieving the document's audit log.`);
            console.log(error);
        });
    
  2. Save and run:

    $ node getDocumentAudit.js
    

Learn more