How to output CakePHP(4.0) log to stdout?

I’m running cakephp(4.0) with docker. how can I output cakephp logs to standard output?
I made the following changes to app.php, but the docker logs {container name} command does not show any logs.

  • Docker version 19.03.12
  • php-fpm
  • nginx
  • php 7.4
  • CakePHP 4.0.4

config/app.php

use Cake\Console\ConsoleOutput;
use Cake\Log\Engine\ConsoleLog;

'Log' => [
        'debug' => [
            'className' => ConsoleLog::class,
            'stream' => 'php://stdout',
            'outputAs' => ConsoleOutput::PLAIN,
            // 'url' => env('LOG_DEBUG_URL', null),
            'scopes' => false,
            'levels' => ['notice', 'info', 'debug'],
        ],
        'error' => [
            'className' => ConsoleLog::class,
            'stream' => 'php://stderr',
            'outputAs' => ConsoleOutput::PLAIN,
            // 'url' => env('LOG_ERROR_URL', null),
            'scopes' => false,
            'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'],
        ],
        // To enable this dedicated query log, you need set your datasource's log flag to true
        'queries' => [
            'className' => ConsoleLog::class,
            'stream' => 'php://stdout',
            'outputAs' => ConsoleOutput::PLAIN,
            // 'url' => env('LOG_QUERIES_URL', null),
            'scopes' => ['queriesLog'],
        ],
    ],

I’ve also tried changing php-fpm options setting “catch_workers_output”, but it doesn’t work.

fpm/pool.d/www.conf

catch_workers_output = yes

Hi, not sure if you ever got an answer to this but I had the same question and ended up getting it working using this configuration -

    'Log' => [
        'debug' => [
            'className' => 'Cake\Log\Engine\ConsoleLog',
            'levels' => ['notice', 'info', 'debug'],
        ],
        'error' => [
            'className' => 'Cake\Log\Engine\ConsoleLog',
            'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'],
        ],
    ],

Based on what I saw in the source, it looks like the default config would take care of everything I needed, thus only specifying to use the ConsoleLog class + the levels configuration.

My issue was logs not being picked up by the awslogs log engine in ECS Fargate. Setting to the above got them picked up.