Express Logger
raw JSON → 0.0.3 verified Thu Apr 23 auth: no javascript abandoned
express-logger is an Express.js middleware, version 0.0.3, last updated in 2011, designed for automatically archiving log files. It extends the functionality of the `express.logger` built-in middleware, providing daily log rotation and archival. This package is specifically tied to older versions of Express (2.x and 3.x) where `express.logger` was still available. It has been effectively abandoned since its last update over a decade ago and is incompatible with modern Express 4.x and later, which replaced `express.logger` with `morgan`. Due to its age, lack of maintenance, and reliance on deprecated Express APIs, it is not recommended for any current Node.js or Express applications and poses significant security and compatibility risks.
Common errors
error TypeError: app.use() requires middleware functions but got a [object Undefined] ↓
cause This error typically occurs when trying to use `express-logger` with Express 4.x or newer. The underlying `express.logger` middleware that `express-logger` extends was removed from Express and is therefore `undefined` when invoked.
fix
Do not use
express-logger with Express 4.x+. Replace it with morgan for request logging and a separate log rotation solution for archiving. error TypeError: Cannot read properties of undefined (reading 'length') at module.exports ↓
cause This error can appear in specific scenarios when `express-logger` is instantiated, particularly if the `express` object it expects is not correctly configured or if internal assumptions of the 2011 codebase conflict with the environment.
fix
This specific error often points to deeper compatibility issues with modern environments. The recommended fix is to replace
express-logger entirely with current logging libraries. Warnings
breaking The `express-logger` package is fundamentally incompatible with Express.js versions 4.x and later. It relies on the built-in `express.logger` middleware, which was removed from Express starting with version 4.0 and replaced by `morgan` as a separate package. Attempting to use `express-logger` with modern Express will result in runtime errors. ↓
fix Migrate to `morgan` for request logging and a dedicated log rotation library (e.g., `winston`, `pino` with logrotate capabilities, or `rotating-file-stream`) for archiving.
gotcha This package is effectively abandoned. It was last published in 2011 (version 0.0.3) and has received no updates or maintenance since. Using abandoned software in production carries significant security risks, as unpatched vulnerabilities could be exploited. It is also unlikely to be compatible with recent Node.js versions or dependencies. ↓
fix Avoid using this package. Consider modern, actively maintained logging solutions like `winston`, `pino`, or `bunyan` for robust logging and `morgan` for HTTP request logging, combined with file rotation utilities.
gotcha The package specifies Node.js engine requirement `>=0.4.0`, an extremely outdated version of Node.js. Running this package on modern Node.js versions (e.g., Node.js 14+) may lead to unexpected behavior or errors due to breaking changes in the Node.js runtime and its core modules over the last decade. ↓
fix Upgrade to a modern logging and archiving solution compatible with current Node.js LTS releases.
Install
npm install express-logger yarn add express-logger pnpm add express-logger Imports
- logger
const logger = require('express-logger');
Quickstart
const express = require('express');
const logger = require('express-logger');
const app = express();
const port = 3000;
const path = require('path');
const fs = require('fs');
// Ensure log directory exists for the example
const logDirPath = path.join(__dirname, 'logs');
if (!fs.existsSync(logDirPath)) {
fs.mkdirSync(logDirPath, { recursive: true });
}
// NOTE: This setup is ONLY for Express versions 2.x or 3.x.
// It is incompatible with Express 4.x and later because `express.logger` was removed.
app.use(logger({ path: path.join(logDirPath, 'access.log') }));
app.get('/', (req, res) => {
res.send('Hello World! Check your logs in the ' + logDirPath + ' directory.');
});
// Basic error handling middleware for demonstration (older Express versions)
app.use((err, req, res, next) => {
console.error(err.stack);
res.status(500).send('Something broke!');
});
app.listen(port, () => {
console.log(`Express app listening at http://localhost:${port}`);
console.log('Access logs will be written to:', path.join(logDirPath, 'access.log'));
console.log('\nWARNING: This package is abandoned and incompatible with modern Express versions (4.x+).');
console.log('Do NOT use this in production or with recent Node.js/Express installations.');
});
// To clean up log directory after testing, manually delete the 'logs' folder created in the script's directory.