title: How to use the logger in a console command on Symfony 4?
body: <p>I've recently gone from using Symfony 2.7 to 4.2.</p>
  
  <p>Previously in my commands in order to log to a file I used something like:</p>
  
  <pre><code>$logger = $this-&gt;getContainer()-&gt;get('logger');
  $logger-&gt;error('put this in log');
  </code></pre>
  
  <p>This functionality appears to have changed.  I can log from a controller following <a href="https://symfony.com/doc/current/logging.html" rel="nofollow noreferrer">https://symfony.com/doc/current/logging.html</a></p>
  
  <p>I can output to the console using:</p>
  
  <pre><code>$logger = new ConsoleLogger($output);
  $logger-&gt;log('error','Put this in the log file');
  </code></pre>
  
  <p>But as much as I stare at the information on the symfony website I just can't figure out how to log to a file using symfony 4.2 from a command.  </p>