Back to Home

Universal Logger (UniLog) Usage Documentation

What is UniLog?

UniLog is a logging platform that can be used to record activities and statuses of your services or customer applications. UniLog supports 4 logging levels: INFO, WARNING, ERROR, CRITICAL.

Besides logging, UniLog also provides a Heartbeat Monitor feature to monitor the uptime of your services and applications. To use the Heartbeat Monitoring feature, you just need to input the URL of the services you want to monitor.

How to Integrate Logging

To integrate logging into your application, send requests to the following endpoint:

https://unilog.my.id/api/logger

Make sure to include the X-API-KEY header with your provided API key.

Basic JSON Payload Structure

The JSON payload sent to UniLog must follow this basic structure:

{
  "event": "",        // Describes the event in the log
  "action": "",       // HTTP method: POST, GET, PUT, DELETE, PATCH
  "level": "",        // Log urgency level
  "message": "",      // Message describing the event
  "status_code": ,    // Status or response code, e.g. if your app sends a request to create a transaction and generate a Virtual Account but fails, send 500 as an integer
  "tags": [""]        // Log categorization or tags (strings)
}

Available Logging Levels

Logging Payload Examples

Authentication Event Logging (INFO level)

{
  "event": "teacher_login",
  "action": "POST",
  "level": "INFO",
  "message": "John Doe successfully logged in",
  "status_code": 200,
  "tags": ["auth"]
}

Product Checkout Process (INFO level)

{
  "event": "checkout_product",
  "action": "POST",
  "level": "INFO",
  "message": "John Doe checks out products",
  "request_data": {
    "user_id": 12345,
    "cart_id": 98765,
    "products": [
      {
        "product_id": 1001,
        "name": "Mechanical Keyboard",
        "quantity": 1,
        "price": 550000
      },
      {
        "product_id": 1002,
        "name": "Wireless Mouse",
        "quantity": 2,
        "price": 200000
      }
    ],
    "total_amount": 950000,
    "payment_method": "Bank Transfer"
  },
  "status_code": 201,
  "tags": [
    "Checkout",
    "E-Commerce",
    "User Action"
  ]
}

Checkout Error from Payment Gateway (ERROR level)

{
  "event": "checkout_product",
  "action": "POST",
  "level": "ERROR",
  "message": "John Doe failed to checkout: payment gateway did not return order_id and failed to create virtual account.",
  "request_data": {
    "user_id": 12345,
    "cart_id": 98765,
    "products": [
      {
        "product_id": 1001,
        "name": "Mechanical Keyboard",
        "quantity": 1,
        "price": 550000
      }
    ],
    "total_amount": 550000,
    "payment_method": "Bank Transfer"
  },
  "response_data": {
    "error_code": "PG-001",
    "error_message": "Failed to generate order_id",
    "gateway_response": {
      "status": "error",
      "message": "Invalid merchant credentials or system timeout",
      "timestamp": "2025-06-01T14:23:10Z"
    }
  },
  "status_code": 500,
  "tags": [
    "Checkout",
    "Payment Gateway Error",
    "E-Commerce",
    "Failure"
  ]
}