🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

pino-http

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
p

pino-http

High-speed HTTP logger for Node.js

10.5.0
latest
100

Supply Chain Security

100

Vulnerability

100

Quality

89

Maintenance

100

License

Version published
Weekly downloads
1.5M
-4.58%
Maintainers
4
Weekly downloads
 
Created
Issues
39

What is pino-http?

pino-http is an HTTP logger middleware for Node.js that integrates with the Pino logging library. It provides high-performance logging for HTTP requests and responses, making it suitable for production environments where speed and efficiency are critical.

What are pino-http's main functionalities?

Basic HTTP Logging

This code sets up a basic HTTP server with pino-http middleware to log incoming requests and outgoing responses.

const http = require('http');
const pino = require('pino');
const pinoHttp = require('pino-http');

const logger = pino();
const httpLogger = pinoHttp({ logger });

const server = http.createServer((req, res) => {
  httpLogger(req, res);
  res.end('hello world');
});

server.listen(3000);

Custom Log Levels

This code demonstrates how to set custom log levels for the pino-http logger.

const http = require('http');
const pino = require('pino');
const pinoHttp = require('pino-http');

const logger = pino({ level: 'debug' });
const httpLogger = pinoHttp({ logger });

const server = http.createServer((req, res) => {
  httpLogger(req, res);
  res.end('hello world');
});

server.listen(3000);

Custom Log Formatting

This code shows how to customize the log output format using Pino's prettyPrint options.

const http = require('http');
const pino = require('pino');
const pinoHttp = require('pino-http');

const logger = pino({
  prettyPrint: {
    colorize: true,
    translateTime: 'SYS:standard',
    ignore: 'pid,hostname'
  }
});
const httpLogger = pinoHttp({ logger });

const server = http.createServer((req, res) => {
  httpLogger(req, res);
  res.end('hello world');
});

server.listen(3000);

Other packages similar to pino-http

FAQs

Package last updated on 03 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts