<p>I've run into a very strange issue where I don't seem to be getting any stdout/stderr output from a Haskell application when run via Kubernetes.</p>

<p>I'm using very basic <code>putStrLn</code> to write to stdout.</p>

<p>If I manually enter the container within the Kubernetes environment and run the application via the shell - I see the expected output.</p>

<p>What may be the cause of this issue/</p>

Chris Stryczynski
<p>It seems this is caused by the output buffering being set in "block" mode when being output to the kubernetes logging.</p>

<p>Fixed via setting the buffering to <code>LineBuffering</code>:</p>

<pre><code>import System.IO

...
  hSetBuffering stdout LineBuffering
  hSetBuffering stderr LineBuffering
</code></pre>

<p><a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/System-IO.html#t:BufferMode" rel="nofollow noreferrer">http://hackage.haskell.org/package/base-4.12.0.0/docs/System-IO.html#t:BufferMode</a></p>

<blockquote>
  <p>The default buffering mode when a handle is opened is
  implementation-dependent and may depend on the file system object
  which is attached to that handle. For most implementations, physical
  files will normally be block-buffered and terminals will normally be
  line-buffered.</p>
</blockquote>

<p>Thanks to Jesse Kempf from the fp slack for pointing me to this!</p>
