Skip to main content

Prerequisites

Install SDK

To install the SDK, run the following:

Import the Axiom transport for Winston

Create a Winston logger instance

Replace API_TOKEN with the Axiom API token you have generated. For added security, store the API token in an environment variable.Replace DATASET_NAME with the name of the Axiom dataset where you send your data.
After setting up the Axiom transport for Winston, use the logger as usual:

Error, exception, and rejection handling

To log errors, use the winston.format.errors formatter. For example:
To automatically log exceptions and rejections, add the Axiom transport to the exceptionHandlers and rejectionHandlers. For example:
Running on Edge runtime isn’t supported.

Configure region

By default, the transport sends data to api.axiom.co. To target a specific edge region, set the edge option on AxiomTransport to the edge domain that matches the region your dataset lives in:
The following edge domains are available: For more information about edge deployments, see Edge deployments.
Always use the edge option to target a region. Don’t put a regional hostname in urlurl is reserved for non-ingest API operations and won’t route ingest correctly. (This is unrelated to the Edge runtime note above, which is about where your code runs.)

Transport options

Examples

For more examples, see the examples in GitHub.