{"id":17133,"library":"express-logging","title":"Express Request/Response Logger Middleware","description":"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.","status":"abandoned","version":"1.1.1","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/telefonica/node-express-logging","tags":["javascript","logging","express","middleware"],"install":[{"cmd":"npm install express-logging","lang":"bash","label":"npm"},{"cmd":"yarn add express-logging","lang":"bash","label":"yarn"},{"cmd":"pnpm add express-logging","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This package is an Express middleware and requires Express to function.","package":"express","optional":false},{"reason":"While not a hard dependency, express-logging requires a logger library with an `.info` method. `logops` is used as the primary example in the documentation.","package":"logops","optional":true}],"imports":[{"note":"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.","wrong":"import expressLogging from 'express-logging';","symbol":"expressLogging","correct":"const expressLogging = require('express-logging');"},{"note":"The logger passed to expressLogging must be a CommonJS module. Ensure your chosen logger exposes an `.info` method.","wrong":"import logger from 'logops';","symbol":"logger","correct":"const logger = require('logops'); // Or your preferred logger"},{"note":"The middleware factory function `expressLogging` must be called with a logger instance as its first argument.","wrong":"app.use(expressLogging); // Missing logger argument","symbol":"app.use","correct":"app.use(expressLogging(logger, options));"}],"quickstart":{"code":"const express = require('express');\nconst expressLogging = require('express-logging');\nconst logger = require('logops'); // Example logger\n\nconst app = express();\n\n// Basic usage: Log all requests/responses\napp.use(expressLogging(logger));\n\n// Example route\napp.get('/', (req, res) => {\n  res.send('Hello, World!');\n});\n\n// Example with custom options: blacklist '/images' and use 'params' policy\nconst blacklistPaths = ['/images', '/html'];\napp.use('/api', expressLogging(logger, { blacklist: blacklistPaths, policy: 'params' }));\n\napp.get('/images/test.png', (req, res) => {\n  res.send('This image access should not be logged by the second middleware.');\n});\n\napp.get('/api/data', (req, res) => {\n  res.json({ message: 'API data' });\n});\n\nconst PORT = process.env.PORT ?? 3000;\napp.listen(PORT, () => {\n  console.log(`Server listening on port ${PORT}`);\n});","lang":"javascript","description":"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."},"warnings":[{"fix":"Consider using a modern, actively maintained logging middleware for Express such as `morgan`, `pino-http`, or `winston-express`.","message":"This 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.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Migration to a contemporary logging solution is strongly recommended to ensure compatibility and leverage modern Node.js features.","message":"The 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"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.","cause":"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.","error":"TypeError: expressLogging is not a function"},{"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.","cause":"The `express-logging` middleware expects the provided logger object to have an `info` method that accepts string formatting or a params object.","error":"TypeError: logger.info is not a function"}],"ecosystem":"npm","meta_description":null}