Skip to content

[BUGFIX] Send the remaining logs of the services to the container log - #657

Draft
Kanti wants to merge 8 commits into
masterfrom
bugfix/logs-to-container-log
Draft

Kanti wants to merge 8 commits into
masterfrom
bugfix/logs-to-container-log

Conversation

@Kanti

@Kanti Kanti commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Update after the review

The review asked whether every line can be told apart, how cron handles stdout and stderr, and which images were tested without LOG_*. Decisions taken from it:

Changes since the review:

  • syslog-ng: messages up to the level warning go to /docker.stdout, those from the level err to /docker.stderr (filters f_stdout, f_stderr; destinations d_stdout, d_stderr). 10-init.sh switches each of the two to file() where it is not a pipe.
  • When the file of LOG_STDOUT or LOG_STDERR cannot be created or written (missing or read-only directory), /docker.stdout or /docker.stderr points back to the container log, and the log says Cannot write to <file> of LOG_STDOUT: its logs stay in the container log. With this pull request, supervisord opens /docker.stdout for every service; without the fallback, no service started (unknown error making dispatchers for 'crond': ENOENT), found by the image tests.
  • Docs: "Logs" in docs/customization.md describes the mixed container log, the split of syslog by level and a table of how the lines tell their source; LOG_STDOUT and LOG_STDERR are marked as not recommended.
  • Tests without LOG_* (the container of the class): NginxChecks::testNginxLogsToTheContainerLogByDefault and ApacheChecks::testApacheLogsToTheContainerLogByDefault (a 403: the access line on stdout only, the error on stderr only; one helper in ImageTestCase), NginxChecks::testNginxMainErrorLogToTheContainerStderrByDefault (kill -9 of a worker), SyslogChecks::testSyslogWritesErrorsToTheContainerStderrAndTheRestToItsStdout; testSyslogKeepsTheOwnerAndModeOfTheContainerStdout also checks that both stay pipes. With LOG_*: SyslogChecks::testSyslogWritesErrorsToTheFileOfLogStderrAndTheRestToTheFileOfLogStdout. testContainerStartsWhenTheFileOfLogStdoutCannotBeCreated now also checks that cron runs and that syslog reaches the container stdout.
  • Removed: the checks that started syslog-ng in images without it (START_SYSLOG); since [!!!][TASK] Stop building bootstrap, base, base-app and dockerfile-build-env, and run the CI on the runners #662 every tested image starts syslog-ng.
  • Verified: all image tests of php, php-nginx and php-apache, each 8.4 and 8.4-alpine, on the published images with the conf/ of this branch copied over. All pass except tests that the overlay itself breaks (build scripts and installers copied back in: testBuildScriptsWereRunAndDeleted, testInstallerIsKeptOnlyForTheServicesTheImageDoesNotRun) and, in Alpine, the installs through apk that the network of the test machine refuses (testAdditionalServiceStarts, testDnsmasqWithVirtualHostsFromTheEnvironment).
  • Behaviour change: messages of syslog from the level err, for example of Postfix, go to the stderr of the container or the file of LOG_STDERR instead of stdout.

The text below describes the pull request before the review; base and base-app were removed since (#662).

Why

#656 sent the logs of PHP-FPM to /docker.stdout and /docker.stderr. An audit of all the other logs of the images, below, found logs that did not reach the container log (docker logs), or not the files of LOG_STDOUT and LOG_STDERR where those are set:

  • sshd logs to syslog with the facility auth, which syslog-ng drops (not facility(auth, authpriv)). A failed login showed up nowhere in the -dev images.
  • What the services print themselves went to the container log also with LOG_STDOUT and LOG_STDERR, because supervisord wrote it to /dev/stdout and /dev/stderr: the output of cron jobs in Alpine, the messages of the Blackfire agent, the output of the start scripts and their hooks, warnings of syslog-ng, start messages of Postfix in Alpine and of PHP-FPM before it opens its log.
  • The main error log of Nginx in Alpine (messages that belong to no server, such as worker process 89 exited on signal 9) went to /docker.stdout, so to the stdout of the container or the file of LOG_STDOUT: the image's own nginx.conf for Alpine has error_log /docker.stdout.

No upstream issue asks for this directly.

The audit also found that cron in Debian and Ubuntu mails or discards the output of its jobs. Fixing that changes how cron behaves (no mail any more), so it is a pull request of its own: #667. This pull request leaves cron as it is.

Audit

Running containers of the published images with the change of #656 on top (its 20-setup-php-fpm-pool.sh run in the image): php, php-dev, php-nginx, php-nginx-dev, php-apache, php-apache-dev, each 8.5 and 8.5-alpine, and base and base-app ubuntu-22.04 with cron, syslog, postfix, ssh and dnsmasq enabled (php-dev with dnsmasq too). In each container: a request straight to PHP-FPM and over http and https through the web server, each calling error_log(), also with XDEBUG_TRIGGER=1; a 404; a request slower than fpm.pool.request_slowlog_timeout=1s; error_log() and a warning in the PHP CLI; a mail with sendmail; a failed ssh login; logger with the facilities user and auth; a cron job of application that writes to stdout and stderr and runs PHP with a warning. Then find / -xdev -newer <marker> -type f after a cron run, and docker logs with stdout and stderr apart. The -dev images ran a second time with LOG_STDOUT and LOG_STDERR, php-dev a third time with PHP_DEBUGGER=blackfire (with the start script of the agent from master).

"Container log" means docker logs, or the files of LOG_STDOUT and LOG_STDERR where they are set.

Log Where it goes now Reaches the container log Change
supervisord's own messages (spawned: 'nginxd', exited: …) stdout of PID 1 (nodaemon, --logfile /dev/null), also with LOG_STDOUT yes (with LOG_STDOUT: stays in docker logs) none: the log of the process manager stays where docker logs shows it; the docs of TZ and of the healthcheck rely on it. Documented.
What the services print themselves: start scripts and hooks (-> Executing …, Setting php-fpm user to application), warnings of syslog-ng, PHP-FPM's Failed implicitly binding to ::, postfix/postlog: starting the Postfix mail system (Alpine), the Blackfire agent, the output of cron jobs on Alpine supervisord: stdout_logfile=/dev/stdout, stderr_logfile=/dev/stderr yes without LOG_*; no with them: in docker logs, not in the files supervisor.d/*.conf of all services: /docker.stdout and /docker.stderr, so they follow LOG_STDOUT and LOG_STDERR
syslog-ng messages from /dev/log and its own (internal()) to pipe("/docker.stdout") (file() with LOG_STDOUT), with [SYSLOG] yes, except: the facilities auth and authpriv are dropped (filter f_filter); what a service sends before syslog-ng listens (about the first second) is lost after the review: errors to /docker.stderr (above); sshd no longer depends on it (below). The race is left: it only costs start messages (see cron, dnsmasq), and a fix would make each service wait for syslog-ng. Documented.
cron (Debian, Ubuntu): its own messages (CMD, END, (CRON) INFO) syslog yes where syslog-ng runs; (CRON) INFO (pidfile fd = 3) and (Running @reboot jobs) missing in some runs (race); the PAM session lines are authpriv and dropped none (Debian cron has no other log target)
cron (Alpine, BusyBox crond): its own messages syslog yes none
Output of cron jobs, Debian and Ubuntu (stdout, stderr, PHP errors of CLI scripts in jobs) cron mails it with /usr/sbin/sendmail: in php, php-nginx, php-apache (no MTA) discarded, (CRON) info (No MTA installed, discarding output); in the -dev images with Postfix delivered locally to /var/mail/application or /var/mail/root, which grow no #667, not here
Output of cron jobs, Alpine BusyBox crond passes on its stdout and stderr to the job, i.e. supervisord's pipes yes without LOG_*; no with them (in docker logs) the supervisor.d change above; #667 tags it
PHP errors of the CLI (docker exec, docker compose run) stderr of the command (log_errors=1, no error_log) no, by design: the caller sees them; php.error_log gives them a file none (documented since #656)
Postfix syslog (mail); Debian: warnings of newaliases/postsuper, Alpine: postfix/postlog start lines on stderr yes where syslog-ng runs none. Bounces of undeliverable mail go to /var/mail/root: mail, not a log, left.
sshd syslog, facility auth no: syslog-ng drops auth sshd -D -e: sshd logs to its stderr, so to the container stderr or LOG_STDERR, also without syslog-ng
dnsmasq syslog (daemon) yes where syslog-ng runs; its start messages missing in some runs (race) none: --log-facility=- would make dnsmasq exit when SERVICE_DNSMASQ_OPTS sets --log-facility too (illegal repeated flag)
Nginx access log (port 80 and 443) /docker.stdout (vhost.common.d/10-log.conf, access_log of nginx.conf) yes none
Nginx error log of the server (port 80 and 443) /docker.stderr (warn, -dev: info) yes none
Nginx main error log (messages of no server, e.g. worker process … exited on signal 9) Debian: /docker.stderr (notice); Alpine: error_log /docker.stdout in the image's own nginx.conf yes, but on Alpine on stdout and in the file of LOG_STDOUT Alpine nginx.conf: /docker.stderr
Nginx's compiled-in /var/log/nginx links to /var/lib/nginx/logs; nothing written there in the runs n/a none
Apache access log (port 80 and 443) /docker.stdout: CustomLog of conf.d/10-log.conf and the distribution's (other_vhosts_access.log on Debian, access.log in httpd.conf on Alpine), which the build points to /docker.stdout too yes, each request twice in two formats none: which of the two to drop changes a format that users may parse; out of scope
Apache error log (port 80 and 443) /docker.stderr (warn, -dev: info); vhost.ssl.conf sets no log of its own yes none
PHP-FPM master and pool, access log /docker.stderr, /docker.stdout (#656) yes none
PHP errors of PHP-FPM /docker.stderr, through the master (#656) yes none
PHP-FPM slow log slowlog = /docker.stderr, off by default the warning yes; the backtrace only with SYS_PTRACE, otherwise ERROR: failed to ptrace(ATTACH) child …: Operation not permitted none (a Docker default); known issue with cap_add: SYS_PTRACE
Xdebug no xdebug.log; its messages (Could not connect to debugging client) go to PHP's error log yes for PHP-FPM; CLI: stderr of the command none
Blackfire agent --log-file default stderr yes without LOG_*; with them in docker logs the supervisor.d change above
Blackfire probe PHP's error log / stderr ([Error] APM: … Cannot connect to the agent) yes none
docker-healthcheck /proc/1/fd/2 yes (with LOG_STDERR: stays in docker logs) none: documented as container log
Files that grow no file under /var/log changed in any run (Alpine has empty auth.log, error.log, kern.log, mail.log from the build; apk.log/dpkg logs only change with packages); /var/mail/<user> (cron output with Postfix) and /var/mail/root (bounces); state and pid files of Postfix and syslog-ng — /var/mail/<user>: #667; the rest left
/opt/docker/etc/logrotate.d/syslog-ng rotates /var/log/syslog and others; logrotate is not installed and nothing writes these files — none, left
Noise go-replace … Error: no files specified from postfix.d/10-init.sh at every start of Postfix; syslog-ng warnings on stats_freq/use-dns — none, separate fix

What

  • supervisor.d/*.conf of all services (cron, dnsmasq, postfix, ssh, syslog, nginx, apache, php-fpm, blackfire-agent): stdout_logfile=/docker.stdout and stderr_logfile=/docker.stderr instead of /dev/stdout and /dev/stderr. Without LOG_STDOUT and LOG_STDERR, /docker.stdout and /docker.stderr are the stdout and stderr of the container, the same as before; with them, the output goes to the two files. The messages of supervisord itself stay in the container log.
  • provisioning/base/general/bin/service.d/ssh.sh: sshd -D -e, so sshd logs to its stderr, which supervisord passes on, also where no syslog-ng runs.
  • provisioning/nginx/alpine/etc/nginx/nginx.conf: error_log /docker.stderr, as in Debian.
  • syslog-ng and the fallback of LOG_*: see "Update after the review".
  • Image tests: see below and above. The hook of syslog-ng writes a line to stdout and one to stderr.
  • Docs:
    • docs/customization.md: a section "Logs" with where each service logs, what supervisord passes on, that syslog-ng drops auth/authpriv and loses what a service sends before it listens, the mixed container log and how its lines tell their source. "supervisord" says to use /docker.stdout and /docker.stderr for a program of your own.
    • docs/environment-variables.md: LOG_STDOUT and LOG_STDERR name what goes there now, that the messages of supervisord stay in the container log, and that they are not recommended; SERVICE_SSH_OPTS is for sshd -D -e.
    • docs/known-issues.md: a new entry for what stays: the slow log of PHP-FPM, which needs SYS_PTRACE for its backtrace (cap_add).
    • docs/README.md, AGENTS.md: one line each.
  • make generate.

Changes in behaviour for existing users

  • With LOG_STDOUT or LOG_STDERR, what the services print themselves goes to these files and no longer to docker logs: the output of the start scripts and hooks of the services, the output of cron jobs in Alpine, the messages of sshd and the Blackfire agent, start errors of Nginx, Apache and PHP-FPM before they open their logs. docker logs keeps the output of the entrypoint, the messages of supervisord itself and of docker-healthcheck.
    • This widens what LOG_STDOUT and LOG_STDERR mean, on purpose: they stand for the container log as a whole, not for the access and error log of the web server. The messages of syslog-ng, for example of cron and Postfix, already went there before. If LOG_STDOUT points at a file that a tool reads as a pure access log, for example /var/log/apache2/access.log, these lines now land there too. The docs of the two variables and the section "Logs" say so.
    • Without LOG_STDOUT and LOG_STDERR, nothing changes: /docker.stdout and /docker.stderr are the stdout and stderr of the container, and the output stays in docker logs, stdout and stderr apart.
  • sshd logs to the stderr of the container, without [SYSLOG] in front, also its start message Server listening on 0.0.0.0 port 22. Before, syslog-ng dropped them.
  • Nginx in Alpine writes its main error log to the stderr of the container or the file of LOG_STDERR, not to stdout.
  • syslog writes messages from the level err to the stderr of the container or the file of LOG_STDERR.

Tests

New image tests, in the environment container, which has LOG_STDOUT and LOG_STDERR:

  • ContainerEnvironmentChecks::testServiceOutputReachesTheFilesFromTheEnvironment: the hook of syslog-ng from Hooks/ writes a line to stdout and one to stderr; they are in the files of LOG_STDOUT and LOG_STDERR.
  • SshChecks::testSshLogsToTheFileFromTheEnvironment (development images): a login of an unknown user over port 2222 fails, and Invalid user image-test-nobody from 127.0.0.1 is in the file of LOG_STDERR.
  • NginxEnvironmentChecks::testNginxMainErrorLogToTheFileFromTheEnvironment (php-nginx, php-nginx-dev): after kill -9 of a worker, [alert] … worker process … exited on signal 9 is in the file of LOG_STDERR, not in that of LOG_STDOUT.

And without LOG_STDOUT and LOG_STDERR:

  • ContainerEnvironmentChecks::testServiceOutputReachesTheContainerLogWithoutTheEnvironment (a container of its own without LOG_*): the two lines of the hook of syslog-ng are in docker logs, the first on its stdout, the second on its stderr.
  • The tests listed under "Update after the review".

The tests with LOG_* do not check that a line is missing from docker logs: at SERVICE_SUPERVISOR_OPTS=--loglevel=trace of the environment container, supervisord repeats the output of the services in its own messages.

Runs before the review, all image tests of each image, before (the published image with the files of master on top, including #656) and after (the same with this change):

Image Before After
php:8.5, php:8.5-alpine, php-apache:8.5, php-apache:8.5-alpine, php-nginx:8.5 testServiceOutputReachesTheFilesFromTheEnvironment fails pass
php-nginx:8.5-alpine it, and testNginxMainErrorLogToTheFileFromTheEnvironment fail pass
php-dev:8.5, php-dev:8.5-alpine, php-nginx-dev:8.5, php-apache-dev:8.5, php-apache-dev:8.5-alpine it, and testSshLogsToTheFileFromTheEnvironment fail pass
php-nginx-dev:8.5-alpine all three fail pass

How it was verified

In the images with the change on top (amd64): the published image with the files of this branch copied over. Where a statement depends on Debian or Alpine, both were checked.

Documented statement Check Result
Alpine: the output of a job goes to the stdout and stderr of the container, or the two files php:8.5-alpine with and without LOG_STDOUT/LOG_STDERR VERIFY-JOB-OUT on stdout or in the file of LOG_STDOUT, VERIFY-JOB-ERR and the PHP warning on stderr or in the file of LOG_STDERR; @reboot jobs too
LOG_STDOUT/LOG_STDERR: supervisord writes there what the services print; its own messages stay in the container log php-nginx:8.5-alpine with both variables and SERVICE_NGINX_OPTS=-Z nginx: invalid option: "Z" in the file of LOG_STDERR, the output of the start scripts and hooks of the services in the file of LOG_STDOUT; docker logs has the output of the entrypoint and the messages of supervisord only
LOG_STDERR: the messages of sshd and the Blackfire agent php-dev:8.5, php-dev:8.5-alpine with PHP_DEBUGGER=blackfire and dummy credentials the errors of the agent (Error sending request to Blackfire API …) in the file, none in docker logs
SERVICE_SSH_OPTS: sshd -D -e, sshd logs to its stderr php-apache-dev:8.5, php-nginx-dev:8.5-alpine: a login of an unknown user; cmdline of sshd Invalid user verify-nobody from 127.0.0.1 port … and Server listening on 0.0.0.0 port 22. on the stderr of the container; /usr/sbin/sshd -D -e
Logs: Nginx and Apache, also for port 443 php-nginx:8.5, php-nginx-dev:8.5-alpine, php-apache-dev:8.5, php-apache:8.5-alpine: https requests for / (403) and a missing page access lines with :443 on stdout, directory index … forbidden / AH01276 on stderr
Logs: the main error log of Nginx goes to /docker.stderr php-nginx-dev:8.5-alpine, php-nginx:8.5: kill -9 of a worker [alert] … worker process … exited on signal 9 on stderr
Logs: syslog-ng drops auth and authpriv, e.g. su su -s /bin/sh application -c true, logger -p auth.info neither in the container log
Logs: what a service sends before syslog-ng listens is lost the start messages of cron and dnsmasq over several starts (audit) (CRON) INFO (pidfile fd = 3) and dnsmasq[…]: started, version … in some starts, missing in others
Logs: at the log level debug, supervisord repeats what the services print php-nginx:8.5 with SERVICE_SUPERVISOR_OPTS=--loglevel=debug DEBG 'syslogd' stdout output: and the line
Known issue: the slow log needs SYS_PTRACE php:8.5, php:8.5-alpine with fpm.pool.request_slowlog_timeout=1s, a request of 3 s, with and without --cap-add SYS_PTRACE without: executing too slow and ERROR: failed to ptrace(ATTACH) child …: Operation not permitted (1); with: the backtrace (sleep() /app/php-test.php:58) in the file of LOG_STDERR
  • Checks of ci/: GrumPHP passes except composer audit, which reports two advisories of symfony/expression-language published on 2026-11-25; they affect master as well.
  • Not verified: arm64, the other PHP versions. This pull request's CI runs the tests on all images on amd64 and arm64.

Some logs of the services did not reach the container log, or not the
files of LOG_STDOUT and LOG_STDERR:

- Cron in Debian and Ubuntu mails the output of a job. Without a mail
  server it discarded it ("No MTA installed, discarding output"); in the
  development images Postfix delivered it to /var/mail/<user>.
  docker-cronjob now begins /etc/cron.d/webdevops-docker with
  SHELL=/usr/local/bin/docker-cronjob-shell. The new script runs the job
  with /bin/sh and sends its stdout and stderr, line by line, to syslog,
  from where syslog-ng writes them to the container log. It keeps the exit
  code of the job and waits up to 10 seconds for syslog-ng, for @reboot
  jobs, which cron runs as soon as it starts.
- sshd logs to syslog with the facility auth, which syslog-ng drops. It
  now runs with -e and logs to its stderr.
- What the services print to their stdout and stderr, for example the
  output of cron jobs in Alpine, the Blackfire agent and sshd, went to the
  container log also with LOG_STDOUT and LOG_STDERR. supervisord now
  writes it to /docker.stdout and /docker.stderr, which are the stdout and
  stderr of the container without the two variables.
- Nginx in Alpine wrote its main error log, e.g. a worker process that
  ended on a signal, to /docker.stdout; now to /docker.stderr.

The image tests check each case in the environment container. The docs
describe where each service logs, the output of cron jobs, and as known
issues the crontab files of your own in Debian and Ubuntu and the slow log
of PHP-FPM without SYS_PTRACE.
The output of the cron jobs of docker-cronjob changes how cron behaves in
Debian and Ubuntu (no mail), so it moves to #667. A new image test checks that
without LOG_STDOUT and LOG_STDERR the output of the services stays in the
container log.
@Kanti
Kanti removed this pull request from stack #659 November 23, 2026 08:17
…ainer-log

# Conflicts:
#	docker/base/ubuntu-22.04/conf/bin/service.d/ssh.sh
#	docker/base/ubuntu-22.04/conf/etc/supervisor.d/cron.conf
#	docker/base/ubuntu-22.04/conf/etc/supervisor.d/dnsmasq.conf
#	docker/base/ubuntu-22.04/conf/etc/supervisor.d/postfix.conf
#	docker/base/ubuntu-22.04/conf/etc/supervisor.d/ssh.conf
#	docker/base/ubuntu-22.04/conf/etc/supervisor.d/syslog.conf
#	docs/customization.md
#	docs/environment-variables.md
Comment thread docs/environment-variables.md Outdated
| `CLI_SCRIPT` | not set | Command the `cli` entrypoint runs as `APPLICATION_USER`. See [Customization](customization.md#commands). |
| `LOG_STDOUT` | container stdout | File that `/docker.stdout` points to. Nginx, Apache and PHP-FPM write their access logs there, syslog-ng the messages of the services, for example of cron and Postfix. |
| `LOG_STDERR` | container stderr | File that `/docker.stderr` points to. Nginx and Apache write their error logs there, PHP-FPM its own messages and the errors of the PHP scripts it runs. `php.error_log` gives the PHP errors of PHP-FPM and the PHP CLI a file of their own instead, in a directory that `application` may write to, for example `/app`. |
| `LOG_STDOUT` | container stdout | File that `/docker.stdout` points to. Nginx, Apache and PHP-FPM write their access logs there, syslog-ng the messages that the services send to syslog, for example of cron and Postfix. supervisord writes there what the services print to their stdout, for example in Alpine the output of cron jobs. The messages of supervisord itself, for example `spawned: 'nginxd'`, stay in the container log. See [Logs](customization.md#logs). |

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Is every service / cron job prefixed in a way that is identifiable?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Claude: Not every one. I checked in php-nginx:8.4 (Debian) and 8.4-alpine with the log routing of this PR:

  • With a name:
    • syslog: [SYSLOG] CRON[85]: …, [SYSLOG] postfix/smtp[…]: …, and [SYSLOG] myapp: … for logger -t myapp.
    • PHP-FPM access log: [php-fpm:access] ….
    • supervisord: … INFO spawned: 'nginxd'.
  • Only by their format, without a prefix:
    • Nginx access log (127.0.0.1 - - […] "GET / HTTP/1.1" 200) and Nginx error log (2026/11/26 … [error] 70#70: …).
    • PHP-FPM itself ([26-Nov-2026 …] NOTICE: …) and the PHP errors it passes on (NOTICE: PHP message: PHP Warning: …).
  • Not at all: the output of cron jobs.
    • In Alpine, crond prints it to its stdout, so it reaches the log as is, without a prefix or the name of the job. Only the time ties it to the line [SYSLOG] crond[50]: USER application pid 82 cmd … before it.
    • In Debian, this PR alone leaves it as before: cron discards it (No MTA installed, discarding output). [FEATURE] Add cron jobs with CRONJOB_<NAME> variables, without an image build #658 sends it to syslog as [SYSLOG] cron-job[<pid>]: …. That says it comes from a cron job, but not from which one.

This PR does not change any of the formats. Before it, the services wrote the same lines to the container log. What is new is that with LOG_STDOUT set, they now all end up mixed in that one file.


Generated by Claude Code

Comment thread docs/customization.md Resolved
Comment thread docs/customization.md
| --- | --- |
| `nginx`, `apache` | Access log to `/docker.stdout`, error log to `/docker.stderr`, also of the virtual host for port 443 |
| `php-fpm` | Access log to `/docker.stdout`; its own messages, the errors of the PHP scripts and the [slow log](known-issues.md#slow-log-of-php-fpm) to `/docker.stderr` |
| `cron` | Its own messages to syslog |

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Dose that mean that cron does not differenciate between stdout and stderr?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Claude: It depends on the distribution. In Alpine, crond keeps them apart: supervisord writes the stdout of a job to /docker.stdout and its stderr to /docker.stderr (checked in php-nginx:8.4-alpine). In Debian, cron itself does not log the output of jobs at all; with this PR alone it still discards it (No MTA installed, discarding output). #658 sends it to syslog, stdout and stderr together, so there both end up in /docker.stdout as [SYSLOG] cron-job[<pid>]: …. The row here is only about the messages of cron itself, for example CRON[85]: (application) CMD (…).


Generated by Claude Code

$container = $this->environmentContainer();
if (!in_array('syslog', self::services(), true)) {
$this->assertCommandSucceeds('docker-service enable syslog && docker-service start syslog', $container);
$this->assertCommandSucceeds(self::START_SYSLOG, $container);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

What container does not start syslog by default?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Claude: None any more. It was for base and base-app, which did not start syslog-ng; #662 removed them. So START_SYSLOG and the three checks for it are dead code now.


Generated by Claude Code

}

$this->eventually(function () use ($container): void {
self::assertStringContainsString('image-test: the hook of syslog-ng on stdout', $this->stdout('cat ' . static::ENVIRONMENT['LOG_STDOUT'], $container));

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

By default we test with LOG_STDOUT/LOG_STSERR set? Is every test case also tested against docker log?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Claude: The class container has no LOG_* variables, the environment container (environmentContainer()) has LOG_STDOUT and LOG_STDERR along with the other variables of ImageTestCase::ENVIRONMENT. Without them, the tests check the container log for the output of the services, for PHP-FPM and for PHP errors; syslog follows with #673. Missing are the access and error logs of Nginx and Apache without the variables.


Generated by Claude Code

…ainer-log

# Conflicts:
#	docs/environment-variables.md
…nd test the container log of the web servers

syslog-ng writes the messages up to the level warning to /docker.stdout and those from the level err to
/docker.stderr, like the access and error logs of the other services, so that a log collector that sets the severity
by the stream marks them as errors. Both targets switch from pipe() to file() on their own when they are files.

The docs describe the mixed container log as it is meant, show how the lines tell their source, and advise against
LOG_STDOUT and LOG_STDERR. New tests check the container log of Nginx and Apache and the split of syslog by severity,
with and without LOG_STDOUT and LOG_STDERR. The checks for images without syslog-ng are gone: no image is left that does
not start it.
…UT or LOG_STDERR cannot be written

supervisord now opens /docker.stdout and /docker.stderr for every service it starts. When the file of LOG_STDOUT or
LOG_STDERR could not be created, for example in a missing or read-only directory, no service started. The entrypoint
now points /docker.stdout or /docker.stderr back to the container log in that case and says so.

The test of the main error log of Nginx waits for Nginx with a request that may answer 403.
@sonarqubecloud

Copy link
Copy Markdown

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.

1 participant