<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Habib Akande</title>
    <description>The latest articles on Forem by Habib Akande (@hakandedotdev).</description>
    <link>https://forem.com/hakandedotdev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3299710%2F127f1197-ea65-456a-b0cd-e87da4c1094c.png</url>
      <title>Forem: Habib Akande</title>
      <link>https://forem.com/hakandedotdev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/hakandedotdev"/>
    <language>en</language>
    <item>
      <title>Fixing Laravel Logs Not Showing in Docker (PHP-FPM + Nginx + Supervisor)</title>
      <dc:creator>Habib Akande</dc:creator>
      <pubDate>Sun, 15 Feb 2026 13:49:33 +0000</pubDate>
      <link>https://forem.com/hakandedotdev/fixing-laravel-logs-not-showing-in-docker-php-fpm-nginx-supervisor-bad</link>
      <guid>https://forem.com/hakandedotdev/fixing-laravel-logs-not-showing-in-docker-php-fpm-nginx-supervisor-bad</guid>
      <description>&lt;p&gt;If you’re running &lt;strong&gt;Laravel inside Docker&lt;/strong&gt; with &lt;strong&gt;PHP-FPM, Nginx, and Supervisor&lt;/strong&gt;, you might run into a confusing issue:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;docker logs &amp;lt;container&amp;gt;&lt;/code&gt; shows nothing
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;storage/logs/laravel.log&lt;/code&gt; is empty
&lt;/li&gt;
&lt;li&gt;Logging &lt;em&gt;looks&lt;/em&gt; configured correctly
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After some digging, the fix turned out to be a &lt;strong&gt;combination of small but critical settings&lt;/strong&gt; across Supervisor, PHP, and Laravel.&lt;/p&gt;

&lt;p&gt;This post documents the working setup.&lt;/p&gt;

&lt;h2&gt;
  
  
  The setup
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Laravel&lt;/li&gt;
&lt;li&gt;PHP-FPM&lt;/li&gt;
&lt;li&gt;Nginx&lt;/li&gt;
&lt;li&gt;Supervisor&lt;/li&gt;
&lt;li&gt;Docker&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Laravel is configured to log to stdout/stderr instead of files.&lt;/p&gt;

&lt;h2&gt;
  
  
  Supervisor must forward logs to stdout/stderr
&lt;/h2&gt;

&lt;p&gt;This is the most important part.&lt;/p&gt;

&lt;p&gt;Supervisor &lt;strong&gt;does not forward process output to Docker by default&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
If this is missing, logs are silently swallowed.&lt;/p&gt;

&lt;p&gt;Make sure each program includes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without this, &lt;strong&gt;docker logs&lt;/strong&gt; will always be empty, even if Laravel is logging correctly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Nginx configuration (optional)
&lt;/h2&gt;

&lt;p&gt;Nothing is strictly required here for Laravel logs.&lt;/p&gt;

&lt;p&gt;If you do want Nginx logs to appear in Docker:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;access_log /dev/stdout;
error_log  /dev/stderr warn;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Otherwise, Nginx can be ignored for this issue.&lt;/p&gt;

&lt;h2&gt;
  
  
  PHP must log errors to stderr
&lt;/h2&gt;

&lt;p&gt;PHP-FPM needs to write errors to Docker’s stderr.&lt;/p&gt;

&lt;p&gt;In php.ini (or a Docker override):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;log_errors=On
error_log=/proc/self/fd/2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This ensures PHP errors show up in docker logs.&lt;/p&gt;

&lt;h2&gt;
  
  
  The real culprit: Laravel logging.php
&lt;/h2&gt;

&lt;p&gt;The main issue is in Laravel’s Monolog configuration.&lt;/p&gt;

&lt;p&gt;This looks correct at first glance, but the stream configuration matters a lot.&lt;/p&gt;

&lt;p&gt;Working configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'stderr' =&amp;gt; [
    'driver' =&amp;gt; 'monolog',
    'level' =&amp;gt; env('LOG_LEVEL', 'debug'),
    'handler' =&amp;gt; StreamHandler::class,
    'formatter' =&amp;gt; env('LOG_STDERR_FORMATTER'),
    'with' =&amp;gt; [
        'stream' =&amp;gt; 'php://stdout',
        'level' =&amp;gt; env('LOG_LEVEL', 'debug'),
    ],
],
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Key takeaways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;strong&gt;stream&lt;/strong&gt; must explicitly point to php://stdout (or stderr)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using &lt;strong&gt;with&lt;/strong&gt; incorrectly can silently break logging&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Laravel does not warn you when Monolog is misconfigured&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is the main reason logs were not appearing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Environment configuration
&lt;/h2&gt;

&lt;p&gt;Final .env setup:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LOG_CHANNEL=stack
LOG_STACK=stderr
LOG_LEVEL=debug
LOG_DEPRECATIONS_CHANNEL=null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don’t forget to clear cached config:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan config:clear
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Final result
&lt;/h2&gt;

&lt;p&gt;With:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Supervisor forwarding stdout/stderr&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;PHP writing errors to stderr&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Laravel correctly streaming logs&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Docker collecting logs&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>laravel</category>
      <category>devops</category>
      <category>php</category>
      <category>docker</category>
    </item>
  </channel>
</rss>
