Skip to content

HashirHussain/http-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

http-logger

A cute and simple middleware for node.js to write/log all HTTP requests to a file.

Usage

var logger = require('http-logger');

logger(options)

Create a http-logger middleware function using the given options. The options argument must be a object of a predefined properties (see below for the properties).

All the options are optional

Options

http-logger accepts three properties in the options object.

dir
  • Type : String
  • Optional : Yes
  • Default value :'http_logger'

Directory name where you want to log the requests. Only pass directory name.

e.g.

logger({
dir:'logToThisFolder'
});
file
  • Type : String
  • Optional : Yes
  • Default value :'http_logger'

File name where you want to log the requests. Only pass file name.

e.g.

logger({
file:'logToThisFile'
});
dateWise
  • Type : Boolean
  • Optional : Yes
  • Default value :false

If set true then new log file will generate each day.

e.g.

logger({
dateWise:true
});

Example

// Require the ingredients we need
var express = require("express");
var http = require("http");
var logger = require("http-logger");

// Build the app
var app = express();

// Use our middleware
app.use(logger());

// Add some middleware
app.use(function(req, res) {
  res.writeHead(200, { "Content-Type": "text/plain" });
  res.end("Hello world!");
});

// Start it up!
http.createServer(app).listen(3000);

About

A cute and simple middleware for node.js that writes/log all HTTP requests to a file

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors