Track users’ logs with morgan
Morgan is a logging middleware used to handle the logging of your admin backend. It is called this way in your app.js file:
const morgan = require('morgan')
...
app.use(morgan('tiny'))
...The logs are printed in this format:

You can choose to have more verbose logs, add new information, and customize the log format using morgan.
You can take a look at the package documentation here.
Add new information
You could add in your logging data like:
user IP (IP of the request),
user name & team from the Forest Admin token
You can adjust the code in your app.js file using the snippet below.
The logs printed will include information about the user IP, the user connected with Forest and his team.
This will give you the following log output:

Customize the format of the logs
You can also use a custom format like a JSON to output your logs.
This will give you the following log output:

Store logs via a stream
You can also choose to store your logs using a stream. The following example shows how you can store your logs into a CSV file.
Last updated
Was this helpful?