title: Laravel x Docker : How can I have STDOUT log from queued jobs?
body: <p>I am running Laravel on php-fpm, <em>docker-composed</em> with Nginx, MySQL.
  I want to have all logs from Laravel job to be visible from <code>docker-compose logs</code> command on Host machine, however, remaining unsuccessful. </p>
  
  <p>Following the official document, I could successfully get logs on STDOUT in Controllers, yet impossible when it comes to Jobs.</p>
  
  <p>Here's my example codes.</p>
  
  <p><strong>Successful example in Controllers</strong></p>
  
  <pre><code>class FormController extends Controller
  {
      public function index(Request $request)
      {
          \Log::channel('stderr')-&gt;info('LOGGING TEST FROM CONTROLLER'); // This works perfectly as expected, i.e. visible with `docker-compose logs` command on the Host!
      }
  }
  </code></pre>
  
  <p><strong>Unsuccessful example in Jobs</strong></p>
  
  <pre><code>class SendMailJob implements ShouldQueue
  {
      public function handle()
      {
          \Log::channel('stderr')-&gt;info('LOGGING TEST FROM JOB'); // This doesn't work X(
      }
  }
  </code></pre>
  
  <p><strong>Supervisor conf file</strong></p>
  
  <pre><code>[program:form]
  command=php /usr/local/laravel/artisan queue:work database --sleep=3 --tries=3
  user=www-data
  environment=HOME="/home/www-data",USER="www-data"
  autostart=true
  numprocs=2
  stdout_logfile=/dev/stdout
  stdout_logfile_maxbytes=0
  stderr_logfile=/dev/stderr
  stderr_logfile_maxbytes=0
  </code></pre>
  
  <p>I would add that Controllers' examples are run through browsers(loading pages), while Jobs are through Supervisor process (php artisan queue:work...).</p>
  
  <p>(And, in my understanding, STDOUT inside container would be reflected to Docker logs. ...is this correct?)</p>
  
  <p><strong>What I've tried</strong></p>
  
  <ol>
  <li><p>checked official document's directions - added <code>\Log::channel('stderr')-&gt;info('TEST');</code> on Controller and accessed corresponding route, which was successful.</p></li>
  <li><p>tried the same method in Job files, which was unsuccessful.</p></li>
  <li><p>add <code>exec('&gt;&amp;2 echo "TEST"');</code> in Job class : also didn't work</p></li>
  <li><p>stopped Supervisor and manually ran <code>php artisan queue:work</code> after changing current user from <code>root</code> to <code>www-data</code>, which is the user running program when I load pages through browser : did actually put out logs in command line, yet invisible from <code>docker-compose logs</code> command.
  *Process through Supervisor is run with user <code>root</code> by default, so I changed it to <code>www-data</code> in conf file. However, as in case with user <code>root</code>, this didn't solve the problem.</p></li>
  </ol>
  
  <p>I'm assuming using of Supervisor might be the reason... but actually have no ideas clearly.</p>
  
  <p>It'd be great if I could see every logs from Laravel apps, when I run <code>docker-compose logs</code> command on Host machine.
  Currently, the command shows only logs in Controller files (i.e. programs which are to be run through browser accesses).</p>
  
  <p>Can anyone help me?
  Any suggestions would be really appreciated.</p>
  
  <p>Thanks!</p>