npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

express-file-logger

v1.0.7

Published

A lightweight, plug-and-play library that logs to a file every endpoint accessed from an Express Server

Downloads

59

Readme

Express-File-Logger


A lightweight, plug-and-play library that logs to a file every access made on an Express Server.


Install

npm install express-file-logger

General Info

With this library, all the hits on an Express' endpoint will be recorded on a text file.

The resulting file will record each access on one or more lines, like the example below:

28/03/2021 00:26:15 [201.23.22.04] (GET) /
28/03/2021 00:26:19 [201.23.22.04] (POST) /api/user/register
  {"name":"Eduardo","email":"[email protected]","password":"pass123"}

Where:

  • 28/03/2021 00:26:15: This field represents the timestamp of the log event
  • [201.23.22.04]: This is the IP address of the visitor
  • (GET), (POST), (HEAD), (PUT), etc: This is the HTTP method of the request
  • /api/user/register: The path of the endpoint
  • {"name":"Eduardo","email":"[email protected]","password":"pass123"}: The body of the request, if any

Basic Usage

To use this library, you only need a valid Express Application object.

Before using it, make sure both libraries are properly installed on your system:

npm install express express-file-logger

Simple Example

Below is an example of how to use this tool.

  1. Import the express library
  2. Create an Express Application
  3. Make sure to use the express.json() middleware before importing this library to have access to the body contents of the requests
  4. Import the express-file-logger, passing the reference to the Express Application that was created in step 2
  5. With the default settings, the log will be saved on your server at '/logs/general_access.log'

Code example

// Import the Express library and get the application reference
const express = require('express')
const app = express()

// This is important if you want the body of the request to be included on the logs
app.use(express.json())

// Import the Express-File-Logger, and initialize it with the Express Application
require('express-file-logger')(app)

app.get('/', (req, res) => {
  res.send('Hi! Very nice to see you around here!')
})

app.listen(3000, console.log('Server is listening on port 3000'))

Options

You can set the following options:

  • basePath
    • Sets the folder where the log file will be saved.
    • Default value is logs
  • fileName
    • The name used for the file
    • Default value is general_access.log
  • ip
    • Boolean value that indicates if the IP address of the visitor will be logged
    • Default value is true
  • showOnConsole
    • Boolean that indicates if the record will also be printed on console
    • Default value is true
  • bodyDetails
    • Boolean that indicates if the body details will be logged
    • Default value is true

These options can be defined on an object and passed in when importing the library:

const express = require('express')
const app = express()
app.use(express.json())

const myOptions = {
  basePath: 'mylogs',
  fileName: 'mysite.log',
  ip: false,
  showOnConsole: false
}
require('express-file-logger')(app, myOptions)
...

Changelog

v1.0.6

  • Better documentation

v1.0.5

  • For better report's visualization, the symbom └─ is now included when the information is span for more than one line.

Previous versions

  • Changed the method used to check if the Express Object is valid
  • Fixes on the text that can be printed on console
  • Other minor fixes
  • README.md changed with better examples on how to use the library

Contact