Skip to content

docker: stream apache/php errors to container stdout and stderr#413

Open
WMP wants to merge 3 commits intokantorge:developfrom
WMP:fix/prod-apache-php-logs
Open

docker: stream apache/php errors to container stdout and stderr#413
WMP wants to merge 3 commits intokantorge:developfrom
WMP:fix/prod-apache-php-logs

Conversation

@WMP
Copy link
Contributor

@WMP WMP commented Feb 19, 2026

This branch improves production log visibility in containerized deployments by routing Apache and PHP logs to container stdout/stderr, so 5xx errors are visible via docker logs without enabling debug mode.

Scope

  • Apache logs:
    • ErrorLog -> stderr (/proc/self/fd/2)
    • CustomLog -> stdout (/proc/self/fd/1)
  • PHP logs:
    • log_errors=On
    • error_log=/proc/self/fd/2
  • Production safety preserved:
    • display_errors=Off
    • display_startup_errors=Off

Why

Previously, runtime failures (e.g. HTTP 500) could be hard to diagnose because only access logs were easily available from the container. This change makes application and runtime errors observable through standard container logging streams.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @WMP, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the observability of containerized applications by reconfiguring Apache and PHP to stream their respective logs directly to the container's stdout and stderr. This change allows developers to easily view critical application and runtime errors, such as HTTP 500s, using standard docker logs commands without needing to enable debug mode, thereby improving diagnostic capabilities in production environments.

Highlights

  • Apache Log Redirection: Apache's ErrorLog is now directed to /proc/self/fd/2 (stderr) and CustomLog to /proc/self/fd/1 (stdout) within the Docker container, centralizing log collection.
  • PHP Error Logging: PHP errors are now explicitly logged (log_errors=On) to /proc/self/fd/2 (stderr) for improved visibility in container logs.
  • Production Safety: The PHP configuration ensures display_errors and display_startup_errors remain Off to maintain production safety while enabling comprehensive error logging.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • docker/Dockerfile
    • Modified Apache configuration to redirect ErrorLog to stderr and CustomLog to stdout.
    • Added a step to copy a new PHP logging configuration file into the image.
  • docker/php-logging.ini
    • New file created to enable PHP error logging (log_errors=On) and direct error_log to stderr.
    • Disabled display_errors and display_startup_errors for production safety.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request aims to improve log visibility in containerized deployments by routing Apache and PHP logs to the container's stdout and stderr. The approach for PHP logging is solid, making the configuration explicit and robust. However, the changes to the Apache configuration in the Dockerfile are redundant, as the php:8.3-apache base image already redirects Apache's logs to stdout/stderr by default. The current implementation using sed is also brittle and could cause issues with future base image updates. I've recommended removing the unnecessary Apache configuration changes.

@kantorge
Copy link
Owner

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request successfully addresses the need for better log visibility in containerized environments by routing Apache and PHP logs to the container's standard output and error streams. This is a best practice for Docker deployments. I have identified an inconsistency in how the Apache configuration is updated, which could lead to some error logs not being captured as expected.

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.

3 participants