Skip to content

Develop#233

Merged
sedv8808 merged 4 commits into
productionfrom
develop
Jul 16, 2026
Merged

Develop#233
sedv8808 merged 4 commits into
productionfrom
develop

Conversation

@sedv8808

Copy link
Copy Markdown
Collaborator

This pull request refactors and improves the logging setup in app.js by 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:

  • Removed the use of rotating-file-stream and the associated log file rotation logic, simplifying dependencies and setup. [1] [2]
  • Added a custom middleware to accurately count and log response body bytes, ensuring correct data volume reporting even when responses are compressed.
  • Updated the request logger to output JSON-formatted logs in production (for easier querying in log analysis tools) and a developer-friendly format in development.
  • Configured the logger to skip health check endpoints to reduce log noise.

** Retention Policy**

Logs will be retained for 2 years - this was set up on AWS

Copilot AI review requested due to automatic review settings July 16, 2026 19:08
@sedv8808
sedv8808 merged commit 50ca8fd into production Jul 16, 2026
3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 thread app.js
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 thread app.js
Comment on lines +122 to +124
app.use(env === 'production'
? morgan(jsonAccessFormat, { stream: process.stdout, skip: skipHealthChecks })
: morgan('dev'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants