Develop#233
Merged
Merged
Conversation
API-57 request logs to stdout as JSON for CloudWatch
API-57 Fixing cloudwatch to not have additional noise
There was a problem hiding this comment.
Pull request overview
This PR refactors request logging in app.js by removing rotating-file-stream file logging and switching to stdout logging, with structured JSON logs in production and a human-readable format in development. It also adds middleware intended to provide a reliable response-size metric when compression() removes Content-Length.
Changes:
- Removed rotating file stream access logging and related rotation logic.
- Added a response byte-counting middleware and wired it into the access log output.
- Updated morgan configuration to emit JSON logs in production and skip healthcheck noise (partially).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+74
to
+78
| // compression() strips Content-Length, so morgan's :res[content-length] token is | ||
| // empty for gzipped responses (i.e. almost all real traffic). Count the response | ||
| // body bytes ourselves so the "data volume" reporting keeps working. Registered | ||
| // after compression() so it counts the uncompressed body the app produced, which | ||
| // matches Content-Length when that header is present. |
Comment on lines
+122
to
+124
| app.use(env === 'production' | ||
| ? morgan(jsonAccessFormat, { stream: process.stdout, skip: skipHealthChecks }) | ||
| : morgan('dev')); |
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 refactors and improves the logging setup in
app.jsby removing the rotating file stream logger and implementing a custom request logging solution. The new logger outputs JSON logs in production for better integration with log analysis tools, and a readable format in development. It also ensures accurate logging of response sizes, even when compression is used.Logging improvements:
rotating-file-streamand the associated log file rotation logic, simplifying dependencies and setup. [1] [2]** Retention Policy**
Logs will be retained for 2 years - this was set up on AWS