Skip to content

Instantly share code, notes, and snippets.

@leommoore
Last active November 14, 2024 05:46
Show Gist options
  • Save leommoore/7524073 to your computer and use it in GitHub Desktop.
Save leommoore/7524073 to your computer and use it in GitHub Desktop.
Express - Logging

#Express - Logging Express comes with a built-in logging module called logger and you can use it just like any other Express module:

app.use(express.logger());

Without any configuration, the logger middleware will generate a detailed log. If you prefer, you can customize the details with the following options to format the output of the logger:

Token Content
:req[header] The specific HTTP header of the request
:res[header] The specific HTTP header of the response
:http-version The HTTP version
:response-time How long it took to generate the response
:remote-addr The user agent's IP address
:date Date and time of request
@hamx0r
Copy link

hamx0r commented Sep 13, 2017

This all still seems valid, but logger now needs to be installed separately and has been renamed morgan

@myxibrium
Copy link

yeah, that's really stupid and confusing. The lack of good logging support out of the box in express is really stupid. There is no single use-case for zero logging support period. Plus Morgan only supports 3 datetime formats, in only UTC, and doesn't allow custom formats.

@khuzema786
Copy link

yeah, that's really stupid and confusing. The lack of good logging support out of the box in express is really stupid. There is no single use-case for zero logging support period. Plus Morgan only supports 3 datetime formats, in only UTC, and doesn't allow custom formats.

Khud banalo bhai tum

@Devendra0110
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment