API-57 request logs to stdout as JSON for CloudWatch#231
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the Express request-logging configuration to better suit production deployments (e.g., AWS App Runner/CloudWatch) by removing file-based rotation and emitting structured access logs.
Changes:
- Removed
rotating-file-streamusage and related log filename/rotation logic. - Added a production JSON access log format intended for CloudWatch Logs Insights and introduced healthcheck skipping.
- Switched non-production logging to Morgan’s readable
'dev'format.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+77
to
+78
| const skipHealthChecks = (req) => | ||
| req.url === '/healthcheck' || req.url.startsWith('/healthcheck/'); |
Comment on lines
8
to
9
| const morgan = require('morgan'); | ||
| const rfs = require('rotating-file-stream'); // version 2.x | ||
| const path = require('path'); |
|
|
||
| const jsonAccessFormat = (tokens, req, res) => JSON.stringify({ | ||
| type: 'access', // discriminator for queries: filter type = "access" | ||
| time: tokens.date(req, res, 'iso'), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request updates the logging setup in
app.jsto simplify request logging and improve compatibility with production environments. The main changes are the removal of therotating-file-streamlog file rotation, and the introduction of a JSON logging format for production, with improved handling for log analysis and health check noise reduction.Logging improvements:
rotating-file-stream-based file logging with logging directly to stdout, removing the dependency onrotating-file-streamand related custom log file naming code. [1] [2]'dev'format for logs.