2018-10-12 15:37:13 -04:00
---
title: Implement a Root-Level Request Logger Middleware
---
2019-07-24 00:59:27 -07:00
# Implement a Root-Level Request Logger Middleware
2018-10-12 15:37:13 -04:00
2019-07-24 00:59:27 -07:00
---
## Problem Explanation
2018-10-12 15:37:13 -04:00
It is easier to write this challenge all at the top (there is already a stub for it). This is because middleware must be placed the function calls you want it to be used for.
2019-07-24 00:59:27 -07:00
---
## Hints
### Hint 1
2018-10-12 15:37:13 -04:00
To set up your own middleware you can do it like so:
```javascript
app.use(function middleware(req, res, next) {
// Do something
// Call the next function in line:
next();
});
```
If you have trouble formatting the string correctly, one way to do it looks like:
```javascript
2019-07-24 00:59:27 -07:00
var string = req.method + " " + req.path + " - " + req.ip;
2018-10-12 15:37:13 -04:00
```
2019-07-24 00:59:27 -07:00
#### Relevant Links
2019-03-14 10:10:05 -05:00
- [Express Middleware ](https://expressjs.com/en/guide/using-middleware.html )