Audit Logs

This section discusses how to work with audit logs User Interface (UI) page.

The Audit log provides a comprehensive and informative view of the execution of a specific task. It makes it easy for users to find the information they need and troubleshoot problems. This is also useful for pulling audit reports such as who updated a certain record, any access controle rules violation, etc.

LogApi class is used for logging. In turn, it makes use of the information in the context to log a few information such as flowExecId, taskExecId, transactionId, etc.

Types of Logging

  1. Standard logging: Log basic information using log4j to the console. These show up in the stackdriver logs in the cloud).

LogApi.info("Hello world"); // Standard logging
  1. Audit logging: It logs into DB and also to the console. It has an additional level called “critical” (maps to error for the log4j logging). These logs are collected in the MySql DB. These should be used for important business-level signals.

LogApi.auditLogInfo("Summary", "response", res); //Audit logging
  1. Standard logging along with Result response: It is similar to basic logging, but it also returns a result object. This is useful to log and construct a Result object (for critical, errors, it constructs a “failed” result, for others it constructs “success”). This should be used when you want to log a message and also return the same message in a Result object. This avoids making two calls one to log and another to construct a Result object.

LogApi.infoR("Hello world", "response", res); // Standard logging along with Result response
  1. Audit logging along with Result response: t is similar to audit logging, but it also returns a result object. This should be used when you want to audit log the message and also return the same message in a Result object. This avoids making two calls one to log and another to construct a Result object.

LogApi.auditInfoR("action", "summary", "details", "sourceUid", "response", res) //Audit logging along with Result response

Complete Logging API

public class LogApi {
  
 
  // Standard logs
  
  public static final void debug(String msg, Object... args) {
    ...
  }

  public static final void debug(String msg, Throwable t, Object... args) {
    ...
  }

  public static final void info(String msg, Object... args) {
    ...
  }

  public static final void info(String msg, Throwable t, Object... args) {
    ...
  }

  public static final void warn(String msg, Object... args) {
    ...
  }

  public static final void warn(String msg, Throwable t, Object... args) {
    ...
  }

  public static final void error(String msg, Object... args) {
    ...
  }

  public static final void error(String msg, Throwable t, Object... args) {
    ...
  }

  public static final Result infoR(String msg, Object... args) {
    ...
  }

  // standard logs that return Result object.
  // It ensures that logged and returned messages are same and avoid extra 
  // formatting call.
  public static final Result infoR(String msg, Throwable t, Object... args) {
    ...
  }

  public static final Result warnR(String msg, Object... args) {
    ...
  }

  public static final Result warnR(String msg, Throwable t, Object... args) {
    ...
  }

  public static final Result errorR(String msg, Object... args) {
    ...
  }

  public static final Result errorR(String msg, Throwable t, Object... args) {
    ...
  }

  public static final Result errorR(String msg) {
    ...
  }

 
  // Audit logs - logs on to console and make a record in the database.
  
  public static final void auditLog(Map<String, Object> logObject) {
    ...
  }
  
  public static final void auditLog(Map<String, Object> logObject, boolean permitLogging) {
    ...
  }
  
  
  public static final void auditInfo(String action, String summary, Object detail, String sourceUid, Object ...args) {
    ...
  }

  public static final void auditWarn(String action, String summary, Object detail, String sourceUid, Object ...args) {
    ...
  }

  public static final void auditError(String action, String summary, Object detail, String sourceUid, Object ...args) {
    ...
  }

  public static final void auditCritical(String action, String summary, Object detail, String sourceUid, Object ...args) {
    ...
  }
  
  // a variation of above methods that require no detail and sourceUid
  
  public static final void auditInfo2(String action, String summary, Object ...args) {
    ...
  }

  public static final void auditWarn2(String action, String summary, Object ...args) {
    ...
  }

  public static final void auditError2(String action, String summary, Object ...args) {
    ...
  }

  public static final void auditCritical2(String action, String summary, Object ...args) {
    ...
  }
  
  //audit logs that return Result object.
  // It ensures that logged and returned messages are same and avoid extra 
  // formatting call.
  public static final Result auditInfoR(String action, String summary, Object detail, String sourceUid, Object ...args) {
    ...
  }

  public static final Result auditWarnR(String action, String summary, Object detail, String sourceUid, Object ...args) {
    ...
  }

  public static final Result auditErrorR(String action, String summary, Object detail, String sourceUid, Object ...args) {
    ...
  }

  public static final Result auditCriticalR(String action, String summary, Object detail, String sourceUid, Object ...args) {
    ...
  }

  public static final Result auditInfo2R(String action, String summary, Object ...args) {
    ...
  }

  public static final Result auditWarn2R(String action, String summary, Object ...args) {
   ...
  }

  public static final Result auditError2R(String action, String summary, Object ...args) {
    ...
  }

  public static final Result auditCritical2R(String action, String summary, Object ...args) {
    ...
  }

}

Last updated