This page explains how to send data from a JavaScript app to Axiom.
Capabilities | @axiomhq/js | @axiomhq/logging |
---|---|---|
Send data to Axiom | Yes | Yes |
Query data | Yes | No |
Capture errors | Yes | No |
Create annotations | Yes | No |
Transports | No | Yes |
Structured logging by default | No | Yes |
Send data to multiple places from a single function | No | Yes |
@axiomhq/logging
library is a logging solution that also serves as the base for other libraries like @axiomhq/react
and @axiomhq/nextjs
.
AXIOM_TOKEN
.
DATASET_NAME
with the name of the Axiom dataset where you want to send data.flush()
only before your application exits.
DATASET_NAME
with the name of the Axiom dataset where you want to send data.onError
to the client:
onError
is set to console.error
.
@axiomhq/logging
library includes the following transports:
ConsoleTransport
: Logs to the console.
AxiomJSTransport
: Sends logs to Axiom using the @axiomhq/js library.
ProxyTransport
: Sends logs the proxy server function that acts as a proxy between your application and Axiom. It’s particularly useful when your application runs on top of a server-enabled framework like Next.js or Remix.
Transport
interface:
@axiomhq/logging
library includes the following logging levels:
debug
: Debug-level logs.info
: Informational logs.warn
: Warning logs.error
: Error logs.