[英]SailsJS Log Request Params
所以我的問題是我想將任何請求記錄到我的Sails應用程序中。 基本上,我已經解決了一個無法記錄請求參數的問題。
myRequestLogger: function(req, res, next) {
if (sails.config.environment === 'development') {
console.log('=========================================================');
console.log("Request :: ", req.method, req.url, req.param);
console.log('=========================================================');
}
return next();
},
req.allParams()返回它不是函數,而req.param(...)返回未定義。 我是否必須在其他位置執行此操作? 有人知道我在做什么錯嗎?
布魯諾
編輯
我在http.js中使用默認順序:
order: [
'startRequestTimer',
'cookieParser',
'session',
'passportInit',
'passportSession',
'myRequestLogger',
'bodyParser',
'handleBodyParserError',
'compress',
'methodOverride',
'poweredBy',
'$custom',
'router',
'www',
'favicon',
'404',
'500'
]
找到了答案...順序必須不同。 requestLogger必須在bodyParser之后實現:
order: [
...
'bodyParser',
'myRequestLogger',
'handleBodyParserError',
'...
]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.