I am running a Node.js web server, and when a user navigates to a page, the logs show this:
0|PROJECT_NAME | 2020-05-06T11:38:37: GET /login 200 607.041 ms - 1443
0|PROJECT_NAME | 2020-05-06T11:38:37: GET /stylesheets/normalize.css 200 7.388 ms - 8223
0|PROJECT_NAME | 2020-05-06T11:38:37: GET /stylesheets/skeleton.css 200 6.291 ms - 11921
0|PROJECT_NAME | 2020-05-06T11:38:37: GET /stylesheets/styles.css 200 6.050 ms - 9136
0|PROJECT_NAME | 2020-05-06T11:38:37: GET /javascripts/resultsLoader.js 200 6.336 ms - 1008
0|PROJECT_NAME | 2020-05-06T11:38:37: GET /javascripts/eventListeners.js 200 6.379 ms - 869
0|PROJECT_NAME | 2020-05-06T11:38:37: GET /javascripts/excellentexport.js 200 5.146 ms - 930341
0|PROJECT_NAME | 2020-05-06T11:38:38: GET /images/white_logo.png 200 1.152 ms - 3994
I'd like to show only the request that the user made themselves, not the supplemental GET requests the application makes on behalf of the user:
0|PROJECT_NAME | 2020-05-06T11:38:37: GET /login 200 607.041 ms - 1443
Is there any way to do this with PM2?
You say you would like to show that specific request.
If that is the case the best thing to do is to use grep to see your logs and ignore the lines you don't want. And that is possible since they follow a clear pattern
grep -Pv '/(?:stylesheets|javascripts|images)/' your-log-file.log
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.