Connect Logging Middleware

0.0.1 · abandoned · verified Wed Apr 22

connect-logger is a minimalistic Connect/Express middleware designed for logging incoming HTTP requests. Released in 2013, its latest and only version is `0.0.1`. The package primarily offers basic request logging with customizable format strings for date, status, method, URL, route, and response time. It allows for moment.js-style date formatting, though `moment` itself is not a direct dependency but rather an implied style guide. Due to its age and lack of updates, it is not compatible with modern Node.js versions, contemporary Express APIs, or ES Modules. Its lack of maintenance makes it unsuitable for production use in current environments, as it predates many standard logging practices and security considerations now common in web development.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to integrate connect-logger into an Express application, showing both default and custom logging options.

const express = require('express');
const connectLogger = require('connect-logger');

const app = express();

// Basic usage with default options
app.use(connectLogger());

// Example with custom format and date options
app.use(connectLogger({
  format: '%date %status %method %url - Response time: %time ms',
  date: 'YYYY-MM-DD HH:mm:ss'
}));

app.get('/', (req, res) => {
  res.send('Hello from connect-logger example!');
});

app.get('/test', (req, res) => {
  res.send('Another page!');
});

const port = 3000;
app.listen(port, () => {
  console.log(`Server listening on http://localhost:${port}`);
});

view raw JSON →