Registry / devops / bunyan-axios-serializer

bunyan-axios-serializer

JSON →
library2.0.0jsnpmunverified

A Bunyan serializer for Axios request/response objects, enabling structured logging of HTTP calls with full request/response details including headers, data, and status codes. Current stable version is 2.0.0. Provides a simple way to integrate Axios HTTP logging into any Bunyan-based logging setup. Released 2021-01-26, no release cadence. Key differentiator: minimal configuration, focused solely on Axios serialization.

npm install bunyan-axios-serializer
INSTALL
IMPORT
SIG · BUNYAN-AXIOS-SERIA
B
bunyan-axios-serializer
devopsjavascriptv2.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

axiosSerializer
import { axiosSerializer } from 'bunyan-axios-serializer'
const axiosSerializer = require('bunyan-axios-serializer')
CommonJS require works but TypeScript/ESM may need default import; package exports ESM and CJS.
axiosRequestSerializer
import { axiosRequestSerializer } from 'bunyan-axios-serializer'
import { requestSerializer } from 'bunyan-axios-serializer'
Named serializer for Axios request objects only.
axiosResponseSerializer
import { axiosResponseSerializer } from 'bunyan-axios-serializer'
import { responseSerializer } from 'bunyan-axios-serializer'
Named serializer for Axios response objects only.

Sets up a Bunyan logger with the Axios serializers and logs an Axios request/response.

import bunyan from 'bunyan'; import { axiosSerializer } from 'bunyan-axios-serializer'; import axios from 'axios'; // Create a Bunyan logger with the Axios serializer const log = bunyan.createLogger({ name: 'myApp', serializers: { req: axiosSerializer, res: axiosSerializer, err: bunyan.stdSerializers.err } }); // Make an Axios request and log it axios.get('https://api.example.com/data') .then(response => { log.info({ res: response }, 'Response received'); }) .catch(error => { log.error({ err: error }, 'Request failed'); });
Debug
Known issues
gotchaThe serializer will include sensitive data (headers, request/response body) in logs. Do not use in production without sanitizing secrets.
fix
Use a custom serializer or redact fields in the Bunyan logger configuration.
affects: >=1.0.0
deprecatedAs of version 2.0.0, the package switched from CommonJS to ESM-first. Older versions used CJS.
fix
Update to 2.0.0 and use import syntax; require() still works but is deprecated.
affects: <2.0.0
Errors
Common errors & fixes
SyntaxError: Cannot use import statement outside a module
Using ES Module import syntax in a CommonJS project without ESM support.
fix
Add "type": "module" to package.json or use require() instead.
TypeError: bunyan.createLogger is not a function
Importing bunyan incorrectly; likely using named import instead of default import.
fix
Use import bunyan from 'bunyan' instead of import { createLogger } from 'bunyan'.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
12
Resources
bunyan-axios-serializer — npm install bunyan-axios-serializer · libregistry