{"id":17785,"library":"logger-request","title":"HTTP Request Logger Middleware","description":"logger-request is an HTTP request logging middleware for Node.js, primarily designed for Express applications. It leverages the Winston logging library (specifically Winston v2.3.1 as of its last release, 3.8.0) to provide flexible output options including file logging, console output, and integration with other Winston transports like MongoDB. Key features include daily log rotation, customizable log fields such as process ID, referrer, authentication status, transfer rates, and user agent. The package reached its latest version, 3.8.0, in 2017, and has not received updates since, making it incompatible with modern Node.js versions and the significantly evolved Winston v3+ ecosystem. Its release cadence was active in the mid-2010s but has ceased, rendering it effectively unmaintained.","status":"abandoned","version":"3.8.0","language":"javascript","source_language":"en","source_url":"https://github.com/hex7c0/logger-request","tags":["javascript","request","logger","logging","winston"],"install":[{"cmd":"npm install logger-request","lang":"bash","label":"npm"},{"cmd":"yarn add logger-request","lang":"bash","label":"yarn"},{"cmd":"pnpm add logger-request","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core logging library, specifically requires v2.3.1. Modern Winston (v3+) is not compatible.","package":"winston","optional":false},{"reason":"Provides daily log rotation functionality, requires v1.4.6.","package":"winston-daily-rotate-file","optional":false},{"reason":"Used to log authentication details if the `custom.auth` option is enabled, requires v1.9.0.","package":"basic-authentication","optional":true},{"reason":"Used to log transfer rates if the `custom.transfer` option is enabled, requires v2.1.0.","package":"transfer-rate","optional":true}],"imports":[{"note":"The package primarily uses CommonJS `require()`. While `import logger from 'logger-request'` might work in some transpiled environments, native ESM is not officially supported and its main export is a default function. CommonJS is the intended usage.","wrong":"const { logger } = require('logger-request')","symbol":"logger","correct":"import logger from 'logger-request'"},{"note":"The package exports a function directly which acts as Express middleware, not a named export. The most common usage pattern is requiring the module and then invoking the returned function.","wrong":"import { LoggerMiddleware } from 'logger-request'","symbol":"LoggerMiddleware","correct":"const logger = require('logger-request'); app.use(logger(options));"}],"quickstart":{"code":"const express = require('express');\nconst logger = require('logger-request');\nconst app = express();\n\n// Configure the logger to write to 'app.log' and also display to console\napp.use(logger({\n  filename: 'app.log',\n  console: true,\n  daily: true, // Rotate log file daily\n  winston: {\n    level: 'info',\n    json: true,\n    timestamp: true\n  },\n  custom: {\n    pid: true, // Log process ID\n    referer: true, // Log HTTP referer header\n    agent: true // Log user-agent header\n  }\n}));\n\napp.get('/', (req, res) => {\n  res.send('Hello World!');\n});\n\napp.listen(3000, () => {\n  console.log('Server running on port 3000');\n});\n","lang":"javascript","description":"Demonstrates basic Express integration, setting up the middleware to log requests to both a daily rotating file (`app.log`) and the console with custom fields."},"warnings":[{"fix":"Downgrade Winston to a compatible v2.x version if you must use this package, or migrate to a modern logging solution that supports Winston v3+.","message":"The package is hardcoded to use Winston v2.3.1. It is not compatible with Winston v3.x or later due to significant API changes in Winston's major versions. Attempting to use a newer Winston version will result in errors.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Consider migrating to a currently maintained HTTP request logger middleware for modern Node.js environments.","message":"The package has not been updated since 2017 and has a Node.js engine requirement of `>=4`. It is not officially tested or supported on modern Node.js versions and may encounter runtime issues or security vulnerabilities.","severity":"breaking","affected_versions":">=3.8.0"},{"fix":"Understand that `options.deprecated` controls log timing, not feature deprecation. Use `false` for default behavior (logging on listener) or `true` for logging after response ends.","message":"The `deprecated` option within the `logger(options)` object does not indicate a deprecation of the package itself or a feature. Instead, it's a flag (default `false`) that alters the timing of log writing from the default `listener` to after `res.end()` (if `true`). This naming can be confusing.","severity":"gotcha","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-23T00:00:00.000Z","next_check":"2026-07-22T00:00:00.000Z","problems":[{"fix":"Ensure that your `node_modules` only contains `winston@2.x` if you intend to use `logger-request`. If your project requires Winston v3+, you must migrate away from `logger-request`.","cause":"This error typically occurs when `logger-request` (which depends on Winston v2) is run in an environment where Winston v3 or later is also present or mistakenly assumed. Winston v3 changed its transport architecture significantly.","error":"TypeError: logger.transports.Console is not a constructor"},{"fix":"Install winston: `npm install winston@2` (to match the version `logger-request` expects) or `npm install winston` if you are using an older npm that resolves peer dependencies automatically.","cause":"`winston` is a peer dependency (or strong runtime dependency) of `logger-request` and must be installed explicitly in your project.","error":"Error: Cannot find module 'winston'"},{"fix":"Verify that `logger-request` is correctly installed via `npm install logger-request`. Check for any installation errors or conflicts in your `node_modules` directory.","cause":"This error can occur if `require('logger-request')` returns `undefined`, which might happen if the package's main file is not found or has an error during loading.","error":"TypeError: app.use requires middleware functions but got a [object Undefined]"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}