Registry / observability / express-logging

express-logging

JSON →
library1.1.1jsnpmunverified

express-logging is an Express middleware designed to log incoming requests and outgoing responses. The current stable version is 1.1.1, released over eight years ago, indicating the project is no longer actively maintained. It allows for configurable logging using any logger that exposes an `info` method, such as `logops`, and supports blacklisting specific URL paths to prevent logging. A key differentiator is its 'policy' option, which enables logging in either a single 'message' string format or a 'params' object format, making it suitable for integration with log processing systems like ELK stack. It also automatically calculates and logs the duration of each request-response cycle. Given its age, it is likely incompatible with modern versions of Node.js and Express.

npm install express-logging
INSTALL
IMPORT
SIG · EXPRESS-LOGGING
E
express-logging
observabilityjavascriptv1.1.1
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

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

expressLogging
✓ const expressLogging = require('express-logging');
✗ import expressLogging from 'express-logging';
This package is CommonJS-only and does not support ES modules. Attempting to import it with `import` will result in a syntax error or a default import object.
logger
✓ const logger = require('logops'); // Or your preferred logger
✗ import logger from 'logops';
The logger passed to expressLogging must be a CommonJS module. Ensure your chosen logger exposes an `.info` method.
app.use
✓ app.use(expressLogging(logger, options));
✗ app.use(expressLogging); // Missing logger argument
The middleware factory function `expressLogging` must be called with a logger instance as its first argument.

Demonstrates basic usage of `express-logging` with a standard logger and an example of configuring the middleware with custom blacklist paths and a 'params' logging policy.

const express = require('express'); const expressLogging = require('express-logging'); const logger = require('logops'); // Example logger const app = express(); // Basic usage: Log all requests/responses app.use(expressLogging(logger)); // Example route app.get('/', (req, res) => { res.send('Hello, World!'); }); // Example with custom options: blacklist '/images' and use 'params' policy const blacklistPaths = ['/images', '/html']; app.use('/api', expressLogging(logger, { blacklist: blacklistPaths, policy: 'params' })); app.get('/images/test.png', (req, res) => { res.send('This image access should not be logged by the second middleware.'); }); app.get('/api/data', (req, res) => { res.json({ message: 'API data' }); }); const PORT = process.env.PORT ?? 3000; app.listen(PORT, () => { console.log(`Server listening on port ${PORT}`); });
Debug
Known issues
breakingThis package is no longer maintained and has not been updated in over eight years. It is highly likely to be incompatible with modern versions of Node.js (e.g., Node.js 14+) and Express (e.g., Express 5). Using it may lead to unexpected errors or security vulnerabilities.
fix
Consider using a modern, actively maintained logging middleware for Express such as `morgan`, `pino-http`, or `winston-express`.
affects: >=1.0.0
gotchaThe package explicitly targets older Node.js versions (engines: `>= 0.10.26`). It was last updated to fix compatibility with 'old node releases,' implying it was not designed with current Node.js features or performance characteristics in mind.
fix
Migration to a contemporary logging solution is strongly recommended to ensure compatibility and leverage modern Node.js features.
affects: >=1.0.0
gotchaThe middleware is CommonJS-only. Attempting to use `import expressLogging from 'express-logging';` in an ES module context will fail with a `TypeError: expressLogging is not a function` or a similar module resolution error.
fix
Ensure your project is configured for CommonJS (`"type": "commonjs"` in package.json) or stick to `require()` syntax for this specific package. For ES module projects, choose an alternative middleware.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: expressLogging is not a function
This error typically occurs when attempting to use the `expressLogging` function directly without passing a logger instance, or if importing it incorrectly in an ESM environment.
fix
Ensure you are calling `expressLogging` with a logger argument (e.g., `app.use(expressLogging(logger));`) and that you are using `const expressLogging = require('express-logging');` in a CommonJS context.
TypeError: logger.info is not a function
The `express-logging` middleware expects the provided logger object to have an `info` method that accepts string formatting or a params object.
fix
Verify that the logger object you are passing to `expressLogging` (e.g., `logger`) has a callable `info` method with the expected signature. For instance, `logops` provides this by default.
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies
expressrequiredThis package is an Express middleware and requires Express to function.
logopsoptionalWhile not a hard dependency, express-logging requires a logger library with an `.info` method. `logops` is used as the primary example in the documentation.
Agent activity
24 hits · last 30 days
node
20
OpenAI (training)
2
Amazon
1
Resources
express-logging — npm install express-logging · libregistry