Skip to content
Discussion options

You must be logged in to vote

In case anyone else needs the detail of what to do to make this work:

npm i pino-http

In the existing server.ts file that was generated by the Express template:

import logger from 'pino-http'
// import morgan from 'morgan'

Later in the same server.ts file:

app.use(logger()) // you can pass logger options here to configure the logger, defaults are used here
// app.use(morgan('tiny'))

By default it will log everything, this is a slightly abridged example showing what you can expect to see when it's working:

20:32:56.788] INFO: request completed
    req: {
      "id": 2,
      "method": "GET",
      "url": "/",
      "query": {},
      "params": {},
      "headers": {
        "host": "localh…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@caprica
Comment options

Answer selected by caprica
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants