FAQs on the exercise Open-Source Middleware: Logging
There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
Agree with a comment or answer? Like () to up-vote the contribution!
I am not sure about the ‘tiny’ format in morgan…
in the morgan document,
tiny
The minimal output.
:method :url :status :res[content-length] - :response-time ms
And after passing the exercise, I wonder if the ‘tiny’ format will only send response like ‘Response Sent’ which is only replaced throughout the exercise.
I agree the tiny format might not be useful in many cases, but there are quite a few others with much more information in the log about the request object. I am sure you’ve seen them above tiny. I think perhaps ‘tiny’ is purely used in this example to not overwhelm the express course learner with extra object info like…
:remote-addr - :remote-user [:date[clf]] and HTTP/:http-version" “:referrer” “:user-agent”
Can you think of any example of when you would use ‘tiny’? I’m not sure.
So I’m a little confused. Does Morgan(‘tiny’) just log the appropriate req/res status or does it log each token included in ‘tiny’ every time a request is made?
I ran the code a couple of times. The first was a GET request for ‘cherry’ which is not an appropriate path. The second was a GET request for ‘/beans/cherry’ which elicits the appropriate response. This is what I got in the console.
$ node app.js
Server is listening on port 4001
GET /cherry 404 145 - 1.487 ms
GET /beans/cherry 200 12 - 2.107 ms
It appears each request is logged in the same format.
I hope that answers your question.
I passed te task, but somehow morgan does not log anything when I send requests… And this is not the first time, that somehow happened several times through the path… Maybe a bug?