mirror of
https://github.com/log4js-node/log4js-node.git
synced 2025-12-08 19:26:01 +00:00
docs: add explaining custom format
This commit is contained in:
parent
d03bcae0f7
commit
d9f41f1bb0
@ -48,6 +48,18 @@ app.use(log4js.connectLogger(logger, {
|
||||
}));
|
||||
```
|
||||
|
||||
When you request of POST, you want to log the request body parameter like JSON.
|
||||
The log format function is very useful.
|
||||
Please use log format function instead “tokens” property for use express's request or response.
|
||||
|
||||
|
||||
```javascript
|
||||
app.use(log4js.connectLogger(logger, {
|
||||
level: 'info',
|
||||
format: (req, res, format) => format(`:remote-addr :method :url ${JSON.stringify(req.body)}`)
|
||||
}));
|
||||
```
|
||||
|
||||
Added automatic level detection to connect-logger, depends on http status response, compatible with express 3.x and 4.x.
|
||||
|
||||
* http responses 3xx, level = WARN
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user