JL
EN
Docs Home
Menu
Guides

Send Logs Over HTTP

Ingest logs with POST /log and verify immediate in-memory availability.

guide jsonlog

Send Logs Over HTTP

Purpose: ingest logs over HTTP and verify they are available for immediate retrieval/streaming.

Preconditions

  • JsonLog service is reachable.
  • For private channels, have a Bearer token with matching acc.
  • Always send a JSON request body for POST /log (minimum {}).

API/Script Flow

  1. Send public event:
    • POST /log with JSON payload.
  2. Send channel event:
    • POST /log?cid=<channel_id> with JSON payload.
  3. Read buffered logs:
    • GET /log for public logs.
    • GET /log?cid=<channel_id> for channel logs.

HTTP/curl Flow

JSONLOG_BASE_URL="http://localhost:3002"
ACCESS_TOKEN="<optional_account_token>"

# Public event (no auth required)
curl -sS -X POST "${JSONLOG_BASE_URL}/log" \
  -H "content-type: application/json" \
  --data '{"message":"hello from public","service":"web"}'

# Channel event (auth optional unless channel is private)
curl -sS -X POST "${JSONLOG_BASE_URL}/log?cid=svc-api" \
  -H "authorization: Bearer ${ACCESS_TOKEN}" \
  -H "content-type: application/json" \
  --data '{"message":"channel event","_jsonlog":{"lvl":"info"}}'

# Read public buffer
curl -sS "${JSONLOG_BASE_URL}/log"

# Read channel buffer
curl -sS "${JSONLOG_BASE_URL}/log?cid=svc-api" \
  -H "authorization: Bearer ${ACCESS_TOKEN}"

Validation

  • POST /log returns 200 on accepted payloads.
  • GET /log returns an array.
  • GET /log?cid=<id> returns an array for visible channels, 404 for private channels with wrong account.