You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using morgan logger version 1.9.1 in a service and I'm using custom format function as mentioned in their instructions. In the custom format function, I'm accessing req.route.path as shown in the code below:
The issue is that out of all the requests that I receive on the server, for some of them I get req.route as undefined due to which I don't get the value of path. Likewise, for some requests, probably the same ones, I get values of variables responseTimeInMS & statusCode as undefined. I'm not sure what the issue can be here. Any help is appreciated.
The text was updated successfully, but these errors were encountered:
@brijeshshah13 I believe the request object is passed down from earlier middleware. The existence of req.route.path is dependent on what kind of server and ealier middleware you are running. There's no way to tell from your code snippet, but I would guess that you are putting the logger middleware before the middleware that adds the req.route.path you are expecting.
If you run your application with the inspector enabled it might enable you to find the problem
Description
I'm using morgan logger version 1.9.1 in a service and I'm using custom format function as mentioned in their instructions. In the custom format function, I'm accessing
req.route.path
as shown in the code below:The issue is that out of all the requests that I receive on the server, for some of them I get
req.route
asundefined
due to which I don't get the value ofpath
. Likewise, for some requests, probably the same ones, I get values of variablesresponseTimeInMS
&statusCode
asundefined
. I'm not sure what the issue can be here. Any help is appreciated.The text was updated successfully, but these errors were encountered: