Choose the best reason why logging is crucial when running applications in production.
Think about how developers find and fix problems after deployment.
Logging records important events and errors, helping developers understand what happened and fix issues fast.
Given the following Express middleware code, what will be logged when a GET request is made to '/'?
app.use((req, res, next) => {
console.log(`Request method: ${req.method}, URL: ${req.url}`);
next();
});
app.get('/', (req, res) => {
res.send('Hello World');
});Look at the request method and URL in the middleware log statement.
The middleware logs the HTTP method and URL for every request. A GET request to '/' logs exactly that.
You deployed an Express app with logging middleware, but no logs appear in the production server console. What is the most likely cause?
Think about the order Express processes middleware and routes.
Middleware must be registered before routes to run. If placed after, it won't log requests.
Which option describes the best practice for handling sensitive data in production logs?
Consider user privacy and security risks.
Masking sensitive data protects user privacy and prevents security breaches while still allowing useful logs.
Put these steps in the correct order to add effective logging to an Express app running in production.
Think about installing first, then configuring, then using, then testing.
You first install the library, then configure it, add middleware to use it, and finally test before production.