當node.js express
站點發生錯誤時,其日誌文件不顯示發生錯誤的URL。它顯示以前的請求的網址。但要調試錯誤,我需要知道導致錯誤的網址。如何記錄在node.js中導致錯誤的url
GET /some/local/url?page=2 200 339ms - 68b # previus request
http.js:704 # error request without url
throw new Error('Can\'t set headers after they are sent.');
^
Error: Can't set headers after they are sent.
at ServerResponse.OutgoingMessage.setHeader (http.js:704:11)
我用forever和nginx
。那麼如何讓它顯示導致日誌文件錯誤的url?
您可能能夠使用[錯誤處理中間件(http://expressjs.com/guide.html#error-handling ) – dc5
thanx @ dc5,但是當使用[錯誤處理中間件](http://expressjs.com/guide.html#error-handling)我需要在任何地方調用'next()'我期望錯誤,但錯誤總是跳出你不希望它 –