| 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.
The @axiomhq/js and the @axiomhq/logging libraries are part of the Axiom JavaScript SDK, an open-source project and welcomes your contributions. For more information, see the GitHub repository.
Prerequisites
- Create an Axiom account.
 - Create a dataset in Axiom where you send your data.
 - Create an API token in Axiom with permissions to ingest data to the dataset you have created.
 
Use @axiomhq/js
Install @axiomhq/js
In your terminal, go to the root folder of your JavaScript app and run the following command:Configure environment variables
Configure the environment variables in one of the following ways:- 
Export the API token as 
AXIOM_TOKEN. - 
Pass the API token to the constructor of the client:
 - 
Install the Axiom CLI, and then run the following command:
 
Send data to Axiom
The following example sends data to Axiom:Replace 
DATASET_NAME with the name of the Axiom dataset where you send your data.flush() only before your application exits.
Query data
The following example queries data from Axiom:Replace 
DATASET_NAME with the name of the Axiom dataset where you send your data.Capture errors
To capture errors, pass a methodonError to the client:
onError is set to console.error.
Create annotations
The following example creates an annotation:Use @axiomhq/logging
Install @axiomhq/logging
In your terminal, go to the root folder of your JavaScript app and run the following command:Send data to Axiom
The following example sends data to Axiom:Transports
The@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:
Logging levels
The@axiomhq/logging library includes the following logging levels:
debug: Debug-level logs.info: Informational logs.warn: Warning logs.error: Error logs.