Registry / devops / axios-logger

axios-logger

JSON →
library2.8.1jsnpmunverified

A logging library for Axios HTTP client that beautifies request, response, and error logs using Axios interceptors. Current stable version is 2.8.1, released with no recent updates; development appears maintenance-level. It provides three logger functions (requestLogger, responseLogger, errorLogger) that can be injected directly into Axios interceptors or composed with custom logic. Configuration is available via setGlobalConfig or per-interceptor options, supporting date formatting, prefix text, and custom logger instances. It differentiates from generic HTTP logging tools by being tightly coupled to Axios's interceptor API, making setup trivial for Axios users. TypeScript type definitions are included.

npm install axios-logger
INSTALL
IMPORT
SIG · AXIOS-LOGGER
A
axios-logger
devopsjavascriptv2.8.1
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.

AxiosLogger
import * as AxiosLogger from 'axios-logger';
import AxiosLogger from 'axios-logger';
This package exports named functions, not a default export. The namespace import is required.
requestLogger
import { requestLogger } from 'axios-logger';
import { RequestLogger } from 'axios-logger';
The function name is camelCase 'requestLogger', not PascalCase.
responseLogger
import { responseLogger } from 'axios-logger';
const responseLogger = require('axios-logger').responseLogger;
ESM import is preferred; CJS require works but may cause TypeScript issues.
errorLogger
import { errorLogger } from 'axios-logger';
import { ErrorLogger } from 'axios-logger';
Case-sensitive: 'errorLogger'.
setGlobalConfig
import { setGlobalConfig } from 'axios-logger';
Function to set global configuration before registering interceptors.

Sets up Axios interceptors for request, response, and error logging using axios-logger.

import axios from 'axios'; import * as AxiosLogger from 'axios-logger'; const instance = axios.create(); // Log all requests using the interceptor instance.interceptors.request.use(AxiosLogger.requestLogger); // Log all responses instance.interceptors.response.use(AxiosLogger.responseLogger); // Also log errors instance.interceptors.response.use( (response) => response, AxiosLogger.errorLogger ); // Make a test request instance.get('https://jsonplaceholder.typicode.com/posts/1') .then((response) => console.log('Done'));
Debug
Known issues
deprecatedPackage has not been updated since 2020. No official deprecation notice, but consider actively maintained alternatives.
fix
Evaluate whether logging needs are still met; consider other Axios logging libraries if issues arise.
affects: >=2.0.0
gotchaThe library uses console.log by default for logging. In production environments, you may want to supply a custom logger (e.g., winston).
fix
Pass a custom logger in config: logger: myLogger.info.bind(myLogger)
affects: *
gotchaWhen using TypeScript, attempting to import via default import (e.g., import AxiosLogger from 'axios-logger') will result in a compile error because the module has no default export.
fix
Use namespace import: import * as AxiosLogger from 'axios-logger' or named import: import { requestLogger } from 'axios-logger'
affects: *
gotchaThe library does not support logging for Axios in browser environments out of the box. It is designed for Node.js.
fix
Use only in Node.js backend; for browser, consider alternatives like Axios interceptors with custom console wrapper.
affects: *
gotchaLogger functions (requestLogger, responseLogger) must return the request/response object unchanged for Axios to continue processing. Forgetting to return can break the request chain silently.
fix
Ensure interceptors return the AxiosLogger function result: return AxiosLogger.requestLogger(request);
affects: *
Errors
Common errors & fixes
TypeError: AxiosLogger.requestLogger is not a function
Using incorrect import style (default import) or wrong package name.
fix
Use namespace import: import * as AxiosLogger from 'axios-logger';
Module '"axios-logger"' has no exported member 'RequestLogger'.
Case-sensitive import: requested 'RequestLogger' instead of 'requestLogger'.
fix
Use proper camelCase: import { requestLogger } from 'axios-logger';
TypeError: Cannot read properties of undefined (reading 'use')
Applying interceptor before creating Axios instance or incorrect interceptor type.
fix
Ensure instance is created with axios.create() and interceptor type is correct (e.g., request or response).
Upgrade
Version history
2.8.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
8
Amazon
1
OpenAI (training)
1
Resources
axios-logger — npm install axios-logger · libregistry